[PATCH v2] C++ify gdb/common/environ.c

Sergio Durigan Junior sergiodj@redhat.com
Sun Apr 16 17:32:00 GMT 2017


On Sunday, April 16 2017, Simon Marchi wrote:

> On 2017-04-15 14:50, Sergio Durigan Junior wrote:
>> As part of the preparation necessary for my upcoming task, I'd like to
>> propose that we turn gdb_environ into a class.  The approach taken
>> here is simple: the class gdb_environ contains everything that is
>> needed to manipulate the environment variables.  These variables are
>> stored in two data structures: an unordered_set, good because lookups
>> are O(n), and an std::vector<char *>, which can be converted to a
>> 'char **' and passed as argument to functions that need it.
>
> Forgot to mention (probably a typo) that lookups in the map are O(1)
> on average.  If they were O(n), it wouldn't be better than looking up
> in a vector :).

You're right, they're O(1).  I was thinking about the vector when I
wrote.  Thanks for the correction!

-- 
Sergio
GPG key ID: 237A 54B1 0287 28BF 00EF  31F4 D0EB 7628 65FC 5E36
Please send encrypted e-mail if possible
http://sergiodj.net/



More information about the Gdb-patches mailing list