diff options
author | Marc Mutz <marc.mutz@kdab.com> | 2016-05-09 13:18:20 +0200 |
---|---|---|
committer | Sean Harmer <sean.harmer@kdab.com> | 2016-05-14 16:02:05 +0000 |
commit | 8ac9e30bb13ee09de71fe07ca85d89d8f6605da9 (patch) | |
tree | a465d6d12e931fa84025d9d62d830421172aa714 /src/render/materialsystem/shader.cpp | |
parent | be27013007267f3a5d3eb518fb75580c5d451cff (diff) |
Qt3D: replace QStringLiteral with QLatin1String when appending or comparing
It makes little sense to use QStringLiteral in the following
situations:
- for comparison to a QString, because operator== is overloaded
for QLatin1String.
- when constructing an empty QString, because QLatin1String("")
resolves to sharedEmpty() when converted to QString, which is
preferable to an independent copy of sharedEmpty().
- for strings which are immediately appended to, or which are
appended to other strings.
because no dynamic memory allocation is saved by doing so. But if
the only advantage of QStringLiteral does not apply, all its
disadvantages dominate, to wit: injection of calls to the qstring
dtor, non-sharability of data between C strings and QStringLiterals
and among QStringLiterals, and doubled storage requirements.
Fix by replacing QStringLiteral with QLatin1String or QLatin1Char,
as needed.
Ported one use of QString::number(i) to QLatin1Char('0' + i) where
i is guaranteed to be < 10.
Saves 179B and 2150B, resp., in Input and Render text size on
optimized Linux AMD64 GCC 6.0 builds.
Change-Id: I2e8f43ed085875ce387ffddb18bba37ff21f6cf0
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
Diffstat (limited to 'src/render/materialsystem/shader.cpp')
-rw-r--r-- | src/render/materialsystem/shader.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/render/materialsystem/shader.cpp b/src/render/materialsystem/shader.cpp index 67c9a0da6..b048909f1 100644 --- a/src/render/materialsystem/shader.cpp +++ b/src/render/materialsystem/shader.cpp @@ -408,7 +408,7 @@ void Shader::initializeUniformBlocks(const QVector<ShaderUniformBlock> &uniformB if (uniformsIt->m_blockIndex == uniformBlockDescription[i].m_index) { QString uniformName = *uniformNamesIt; if (!m_uniformBlockNames[i].isEmpty() && !uniformName.startsWith(m_uniformBlockNames[i])) - uniformName = m_uniformBlockNames[i] + QStringLiteral(".") + *uniformNamesIt; + uniformName = m_uniformBlockNames[i] + QLatin1Char('.') + *uniformNamesIt; activeUniformsInBlock.insert(uniformName, *uniformsIt); qCDebug(Shaders) << "Active Uniform Block " << uniformName << " in block " << m_uniformBlockNames[i] << " at index " << uniformsIt->m_blockIndex; } |