diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2022-10-27 15:55:42 -0700 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2022-11-16 16:15:31 -0800 |
commit | d50d34e5de7f5cf5e34243210e3df519974d7794 (patch) | |
tree | ff86a644a6dc271da7817767e1f7668d7b82ed25 /src/corelib/io/qipaddress.cpp | |
parent | 649dccf57b18626f6a0790d46e5e619e4e603078 (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/qipaddress.cpp')
-rw-r--r-- | src/corelib/io/qipaddress.cpp | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/src/corelib/io/qipaddress.cpp b/src/corelib/io/qipaddress.cpp index eeb3d79b06..feed38bef6 100644 --- a/src/corelib/io/qipaddress.cpp +++ b/src/corelib/io/qipaddress.cpp @@ -60,11 +60,9 @@ static bool parseIp4Internal(IPv4Address &address, const char *ptr, bool acceptL ptr[1] != '.' && ptr[1] != '\0') return false; - const char *endptr; - bool ok; - quint64 ll = qstrntoull(ptr, stop - ptr, &endptr, 0, &ok); + auto [ll, endptr] = qstrntoull(ptr, stop - ptr, 0); quint32 x = ll; - if (!ok || endptr == ptr || ll != x) + if (!endptr || endptr == ptr || ll != x) return false; if (*endptr == '.' || dotCount == 3) { @@ -176,15 +174,13 @@ const QChar *parseIp6(IPv6Address &address, const QChar *begin, const QChar *end continue; } - const char *endptr; - bool ok; - quint64 ll = qstrntoull(ptr, stop - ptr, &endptr, 16, &ok); + auto [ll, endptr] = qstrntoull(ptr, stop - ptr, 16); quint16 x = ll; // Reject malformed fields: // - failed to parse // - too many hex digits - if (!ok || endptr > ptr + 4) + if (!endptr || endptr > ptr + 4) return begin + (ptr - buffer.data()); if (*endptr == '.') { |