This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
On 2017-04-15 00:36, Simon Marchi wrote:
On 2017-04-10 08:22, Pedro Alves wrote:This main idea behind this patch is this change to xml-support.c:scope_level- /* Body text accumulation. This is an owning pointer. */ - struct obstack *body; + /* Body text accumulation. */ + std::string body; ... which allows simplifying other parts of the code. In target_fetch_description_xml, we want to distinguish between returning "success + empty std::string" and "no success", and gdb::optional is a natural fit for that.When growing a string like that, isn't it more efficient to use a stringstream?
Nevermind, I think I got confused with Java, where string objects are immutable. So every time you do an append, it actually allocates a new string object. It's therefore good practice to use a StringBuilder in those cases. The C++ string works similarly to a vector (with exponential capacity growth), so the number of reallocations is not bad.
Simon
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |