summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2015-12-27 10:20:14 +0100
committerMarc Mutz <marc.mutz@kdab.com>2016-01-04 06:10:45 +0000
commitb20de8a23d74f336d9c24acc384f98157115de9c (patch)
treed090d9b67ff2944adf4fb815d8718c75a14e8555 /src/corelib/io
parent5f542f3cca13f2da58b82aee2efbaffefeee00a7 (diff)
QTranslator: Extract Method is_readable_file from find_translation()
The old code re-used a QFileInfo object, repeatedly setting new file names with QFileInfo::setFile(QString). But QFileInfo::setFile() simply assigns itself a new QFileInfo object: *this = QFileInfo(...) so it's just as efficient to re-create a new QFIleInfo object for every file name under test. To avoid extra {} for object lifetime scoping, factor the repeated evaluation of isReadable() && isFile() into a small helper function, which also creates and destroys the QFileInfo object. The deeper significance of this change is that it avoids implicit sharing of 'realname', which is permanently modified. A later patch will make changes that make 'realname' re-use its capacity through the lifetime of the find_translation() function, and sharing the variable implicitly will nip any auch attempts in the bud. Force the compiler to not inline the new function. There's really no point in spending ~0.5KiB in text size on inlining the code; the miniscule speed improvement is dwarfed by the memory allocation of the QFileInfo ctor, anyway. As a consequence, this change even saves 96b in text size on optimized GCC 4.9 Linux AMD64 builds, even though that wasn't even the goal. Change-Id: I08c5cbb7b6f1ba59440a1597e28d962ce63a7c65 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
0 files changed, 0 insertions, 0 deletions