give the XML tag map and the writer buffer a name

Both of these bound a non-const reference to a temporary, which MSVC accepts
and clang does not, and which leaves the reference dangling once the full
expression ends.

PropertyContainer::initFromXMLFile and writeToXMLFile take their tag map by
non-const reference because the accessors on it insert default tag names as
they are asked for, so it cannot be const and it cannot be a temporary. All
eight call sites passed a freshly built one; they now declare it. Each keeps
its own object, so a map filled in by one call cannot leak into the next, the
same as when each call built its own temporary.

XMLWriter::writeToFile bound std::string& to what stringstream::str() returns
by value. Declared as a value it is initialised straight from the return with
no copy, and const because only c_str() and length() are asked of it.

Verification:

    grep -rn 'PropertyContainer::TagMap()' .   # nothing
    ninja -C build parse         # no i18n or XMLWriter sites remain
    ninja -C build -k 0          # Release, four applications, green
    ninja -C build-debug -k 0    # Debug, four applications, green

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Marco Antonio J. Costa
2026-07-23 19:29:55 -03:00
committed by majcosta
co-authored by Claude Opus 4.8
parent b5ea70aa44
commit e56a372871
3 changed files with 17 additions and 9 deletions
+1 -1
View File
@@ -75,7 +75,7 @@ bool XMLWriter::writeToFile(vfs::tWritableFile* pFile)
try
{
vfs::COpenWriteFile file(pFile);
std::string &str = m_ssBuffer.str();
const std::string str = m_ssBuffer.str();
pFile->write(str.c_str(), str.length() * sizeof(std::string::value_type));
return true;
}