summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qstorageinfo_unix.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2022-10-27 15:55:42 -0700
committerThiago Macieira <thiago.macieira@intel.com>2022-11-16 16:15:31 -0800
commitd50d34e5de7f5cf5e34243210e3df519974d7794 (patch)
treeff86a644a6dc271da7817767e1f7668d7b82ed25 /src/corelib/io/qstorageinfo_unix.cpp
parent649dccf57b18626f6a0790d46e5e619e4e603078 (diff)
QLocale: make qstrnto(u)ll not have output arguments
That is, return everything in the return argument. On the SysV ABI, that means everything gets returned in registers, in both 32- and 64-bit platforms (unlike QtPrivate::ParsedNumber). There's a minor but perceptible performance improvement in parsing strings and byte arrays. Before: Parsed string "42" "1234" "-1548860221" Clock (ns) 16.673 18.878 25.517 CPU cycles 46.548 52.704 71.243 Instructions 201 233 331 After: Parsed string "42" "1234" "-1548860221" Clock (ns) 15.577 17.998 24.198 CPU cycles 43.491 49.942 67.552 Instructions 179 211 308 On my Core i7-1165G7 @ 2.80 GHz, the 22-23 instruction gain per iteration results in half the expected clock gain in runtime (22 / 2.8 GHz = 7.8 ns) because of a slightly lower instruction per cycle rate. That's acceptable because we need less speculative execution. Pick-to: 6.4 Task-number: QTBUG-107788 Change-Id: I07ec23f3cb174fb197c3fffd17220fd64d473cc0 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/io/qstorageinfo_unix.cpp')
-rw-r--r--src/corelib/io/qstorageinfo_unix.cpp29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp
index 5f3fa32482..be3bf0252d 100644
--- a/src/corelib/io/qstorageinfo_unix.cpp
+++ b/src/corelib/io/qstorageinfo_unix.cpp
@@ -451,32 +451,35 @@ inline bool QStorageIterator::next()
const char *const stop = ptr + len - 1;
// parse the line
- bool ok;
mnt.mnt_freq = 0;
mnt.mnt_passno = 0;
- mnt.mount_id = qstrntoll(ptr, stop - ptr, const_cast<const char **>(&ptr), 10, &ok);
- if (!ok)
+ auto r = qstrntoll(ptr, stop - ptr, 10);
+ if (!r.ok())
return false;
+ mnt.mount_id = r.result;
- int parent_id = qstrntoll(ptr, stop - ptr, const_cast<const char **>(&ptr), 10, &ok);
- Q_UNUSED(parent_id);
- if (!ok)
+ r = qstrntoll(r.endptr, stop - r.endptr, 10);
+ if (!r.ok())
return false;
+ int parent_id = r.result;
+ Q_UNUSED(parent_id);
- int rdevmajor = qstrntoll(ptr, stop - ptr, const_cast<const char **>(&ptr), 10, &ok);
- if (!ok)
+ r = qstrntoll(r.endptr, stop - r.endptr, 10);
+ if (!r.ok())
return false;
- if (*ptr != ':')
+ if (*r.endptr != ':')
return false;
- int rdevminor = qstrntoll(ptr + 1, stop - ptr - 1, const_cast<const char **>(&ptr), 10, &ok);
- if (!ok)
+ int rdevmajor = r.result;
+ r = qstrntoll(r.endptr + 1, stop - r.endptr - 1, 10);
+ if (!r.ok())
return false;
- mnt.rdev = makedev(rdevmajor, rdevminor);
+ mnt.rdev = makedev(rdevmajor, r.result);
- if (*ptr != ' ')
+ if (*r.endptr != ' ')
return false;
+ ptr = const_cast<char *>(r.endptr);
mnt.subvolume = ++ptr;
ptr = parseMangledPath(ptr);
if (!ptr)