[PATCH v2] Implement the ability to set/unset environment variables to GDBserver when starting the inferior

Simon Marchi simon.marchi@polymtl.ca
Tue Aug 1 09:54:00 GMT 2017


On 2017-08-01 04:42, Sergio Durigan Junior wrote:
>> I have the feeling that we can reduce the amount of boilerplate code
>> in the set and unset methods by using std::set instead of std::vector.
>> Performance-wise this may not be very good, since for any reasonable
>> amount of variables, the vector would probably be more efficient.  But
>> its interface makes the code clearer and lighter, in my opinion.  I
>> suppose we could always make something with a set-like interface and
>> behavior implemented on top of a vector.
> 
> I thought about using std::set, but given that I was recently called 
> out
> for doing "premature pessimization", I chose to stick with std::vector.
> I agree that for some cases std::set would make things easier to
> implement/understand.

Yeah, the thing with std::set that simplifies the code is its interface, 
not its implementation.  And it would indeed not be a good idea 
performance-wise (both CPU cycles and memory) to use std::set for 
something that would typically contain a handful of elements at the 
most.  So that's why I think using something that has (part of) the 
interface of an std::set but implemented on top of an std::vector would 
be good.  I'll try to prototype something soon.

Simon



More information about the Gdb-patches mailing list