From 3070efb64a628f5c61fc5870ee4a8791942f6699 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Tue, 11 Feb 2025 16:34:13 +0100 Subject: QCbor/JsonValue: add toStringView() This is like toString(), but returns a view on the underlying string data (which may be US-ASCII (= L1), UTF-8, or UTF-16, so the return value is QASV). Use it around the code a bit. Benchmark results on my machine (with -perf -iterations 1000): PASS : BenchmarkQtJson::iteratorKey() RESULT : BenchmarkQtJson::iteratorKey(): 78,268.426 nsecs per iteration (total: 78,268,427, iterations: 1000) 349,458.080 CPU cycles per iteration, 4,46 GHz (total: 349,458,080, iterations: 1000) 780,327.957 instructions per iteration, 2,233 instr/cycle (total: 780,327,957, iterations: 1000) 173,511.019 branch instructions per iteration, 2,22 G/sec (total: 173,511,020, iterations: 1000) PASS : BenchmarkQtJson::iteratorKeyValueView() RESULT : BenchmarkQtJson::iteratorKeyValueView(): 58,424.756 nsecs per iteration (total: 58,424,756, iterations: 1000) 267,176.603 CPU cycles per iteration, 4,57 GHz (total: 267,176,604, iterations: 1000) 614,805.388 instructions per iteration, 2,301 instr/cycle (total: 614,805,389, iterations: 1000) 140,681.105 branch instructions per iteration, 2,41 G/sec (total: 140,681,106, iterations: 1000) PASS : BenchmarkQtJson::iteratorKeyView() RESULT : BenchmarkQtJson::iteratorKeyView(): 44,060.925 nsecs per iteration (total: 44,060,925, iterations: 1000) 196,344.233 CPU cycles per iteration, 4,46 GHz (total: 196,344,233, iterations: 1000) 426,631.322 instructions per iteration, 2,173 instr/cycle (total: 426,631,323, iterations: 1000) 93,703.100 branch instructions per iteration, 2,13 G/sec (total: 93,703,101, iterations: 1000) PASS : BenchmarkQtJson::iteratorKeyViewValueView() RESULT : BenchmarkQtJson::iteratorKeyViewValueView(): 29,205.569 nsecs per iteration (total: 29,205,570, iterations: 1000) 131,089.040 CPU cycles per iteration, 4,49 GHz (total: 131,089,041, iterations: 1000) 258,529.469 instructions per iteration, 1,972 instr/cycle (total: 258,529,469, iterations: 1000) 60,875.631 branch instructions per iteration, 2,08 G/sec (total: 60,875,631, iterations: 1000) [ChangeLog][QtCore][QCborValue/QJsonValue] Add toStringView() method. Fixes: QTBUG-133688 Change-Id: I4200035e995426f1cce46a73a429921a0cd56c85 Reviewed-by: Thiago Macieira --- src/gui/opengl/qopengl.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gui/opengl/qopengl.cpp') diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index 587975085ad..021c3964219 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -176,8 +176,8 @@ VersionTerm VersionTerm::fromJson(const QJsonValue &v) if (!v.isObject()) return result; const QJsonObject o = v.toObject(); - result.number = QVersionNumber::fromString(o.value("value"_L1).toString()); - const QString opS = o.value("op"_L1).toString(); + result.number = QVersionNumber::fromString(o.value("value"_L1).toStringView()); + const auto opS = o.value("op"_L1).toStringView(); for (size_t i = 0; i < sizeof(operators) / sizeof(operators[0]); ++i) { if (opS == QLatin1StringView(operators[i])) { result.op = static_cast(i); -- cgit v1.2.3