Ticket #10063 (new)

Opened 6 years ago

Last modified 5 years ago

InstrumentDefinitionParser allocates/deallocates a lot of strings

Reported by: Martyn Gigg Owned by: Martyn Gigg
Priority: major Milestone: Backlog
Component: Framework Keywords:
Cc: Blocked By: #10062
Blocking: Tester:

Description (last modified by Martyn Gigg) (diff)

#9860 profiled the IDF loading.

In processing an IDF file we have to check many times whether a given XML document/element has a node or attribute. Most code currently looks like

pTypeElem->hasAttribute("outline");
...

The Poco hasAttribute method only accepts a std::string so each call like this requires an implicit allocation/deallocation of a temporary std::string object.

An improvement that would cut down on the number of these allocations would be to have the tags defined in a separate file within functions or static methods, e.g.

    /// Allocate a static string and return the appropriate tag
    inline const std::string IDFTags::component()
    {
      static const std::string tag = "component";
      return tag;
    }

The static keyword ensures that the allocation only happens once and only the first time the function is actually called.

To summarise, the suggestion is to create a new class, IDFTags, that only has static methods like the one above. This would then be used by the InstrumentDefinitionParser class. Another advantage of this is that we would have a single file where all of the tags are defined, rather than them scattered around the InstrumentDefinitionParser code.

Attachments

IDFParserProfile.png (525.8 KB) - added by Martyn Gigg 6 years ago.

Change History

Changed 6 years ago by Martyn Gigg

comment:1 Changed 6 years ago by Martyn Gigg

  • Description modified (diff)

comment:2 Changed 5 years ago by Stuart Campbell

This ticket has been transferred to github issue 10905

Note: See TracTickets for help on using tickets.