mirror of
https://github.com/zeux/pugixml.git
synced 2025-01-14 01:47:55 +08:00
Use string::append in implementations of xml_writer
The current code is not optimal; since users actually read samples/tests change them to use faster (and shorter!) code.
This commit is contained in:
parent
3181a305ed
commit
650a4c6cca
@ -11,7 +11,7 @@ struct xml_string_writer: pugi::xml_writer
|
||||
|
||||
virtual void write(const void* data, size_t size)
|
||||
{
|
||||
result += std::string(static_cast<const char*>(data), size);
|
||||
result.append(static_cast<const char*>(data), size);
|
||||
}
|
||||
};
|
||||
//]
|
||||
|
@ -171,7 +171,7 @@ struct test_writer: xml_writer
|
||||
virtual void write(const void* data, size_t size)
|
||||
{
|
||||
CHECK(size % sizeof(pugi::char_t) == 0);
|
||||
contents += std::basic_string<pugi::char_t>(static_cast<const pugi::char_t*>(data), static_cast<const pugi::char_t*>(data) + size / sizeof(pugi::char_t));
|
||||
contents.append(static_cast<const pugi::char_t*>(data), size / sizeof(pugi::char_t));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -15,7 +15,7 @@ static bool test_narrow(const std::string& result, const char* expected, size_t
|
||||
|
||||
void xml_writer_string::write(const void* data, size_t size)
|
||||
{
|
||||
contents += std::string(static_cast<const char*>(data), size);
|
||||
contents.append(static_cast<const char*>(data), size);
|
||||
}
|
||||
|
||||
std::string xml_writer_string::as_narrow() const
|
||||
|
Loading…
x
Reference in New Issue
Block a user