When the dictionary classes were changed to use the standard classes, the derived constant number and string information classes were missed because they were in different source files. For adding elements, these classes also used the method of increasing the vector size by one and then setting the new element. This causes the default constructor to be called when the size is increased, and then a copy when the element is set. It is more efficient to use the C++11 emplace functions to construct directly to the new element.
The info dictionary add function previously did the add element (increase vector size) and set element as two separate calls. The add function was changed to pass the token pointer to the add element function and not call the set element when adding an element. The add element functions get a token pointer argument to be used with the emplace back function to add the new element to the end of the value vectors (which were changed to standard vectors). The value vector of the constant string info class was changed to a vector of standard string pointers. The constant string info destructor was changed to use a C++11 range-for loop to delete the strings in this vector.
When dependency on Qt was removed from the dictionary classes, the quint16 type was changed to the standard uint16_t for holding indexes into the dictionaries (in the program code). This change was also missed in the constant info classes. The compiler didn't complain since these two types are the same under the hood. The constant info classes were changed to use uint16_t.
[branch misc-cpp-stl commit 14d3b329b7]
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment
All comments and feedback welcomed, whether positive or negative.
(Anonymous comments are allowed, but comments with URL links or unrelated comments will be removed.)