This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH v2] C++ify gdb/common/environ.c
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: Simon Marchi <simon dot marchi at polymtl dot ca>
- Cc: GDB Patches <gdb-patches at sourceware dot org>
- Date: Sun, 16 Apr 2017 13:32:04 -0400
- Subject: Re: [PATCH v2] C++ify gdb/common/environ.c
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=sergiodj at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 07FB681253
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 07FB681253
- References: <20170413040455.23996-1-sergiodj@redhat.com> <20170415185053.31827-1-sergiodj@redhat.com> <7da1e54fc8f25b39e1e4c9558a77e71a@polymtl.ca>
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/