QCOMPARE/QVERIFY: fix huge pessimisation in QTestResult::reportResult
The old code allocated a stack buffer, but asked the runtime to zero-initialize it. That's 1KiB of writes to the stack on every QCOMPARE and QVERIFY before any actual work is done. Fixing this little laissez-faire to just initialize the first character in the buffer results in nice little speedups of ~40%. This fixes the issue in reportResult(), a Cut'n'paste from compare() and verify(), which have since been fixed by a previous commit. Change-Id: I5cad57299490925b88e768dc751304699274db2e Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
0681a2dd5a
commit
9fea0c613e
@ -629,7 +629,8 @@ bool QTestResult::reportResult(bool success, qxp::function_ref<const char *()> l
|
||||
const char *failureMessage)
|
||||
{
|
||||
const size_t maxMsgLen = 1024;
|
||||
char msg[maxMsgLen] = {'\0'};
|
||||
char msg[maxMsgLen];
|
||||
msg[0] = '\0';
|
||||
|
||||
QTEST_ASSERT(lhsExpr);
|
||||
QTEST_ASSERT(rhsExpr);
|
||||
|
Loading…
Reference in New Issue
Block a user