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 <thiago.macieira@intel.com>