Cache memory buffer's name length
authorserge-sans-paille <sguelton@mozilla.com>
Wed, 23 Nov 2022 06:45:59 +0000 (07:45 +0100)
committerserge-sans-paille <sguelton@mozilla.com>
Thu, 1 Dec 2022 08:38:16 +0000 (09:38 +0100)
commit37048d04d8eefd24af4871bd9428f389eaad0abe
treed19f0711b37e7df268852399c941d9dc82f9d82c
parent5cb68314f34151994266f2c5fc1e8a15d11708c3
Cache memory buffer's name length

This avoids repeated calls to strlen while we already know its value.

When preprocessing sqlite3.c, this gives a surprising 2% speedup.

Full benchmark available here:

https://llvm-compile-time-tracker.com/compare.php?from=d14c2d408dccd8c6defa7d151e9a96be3cac8cc3&to=04f0641c1cbdcd0bdbd11cd910ca6091420bf52e&stat=instructions:u

Recommit 1824432174b3166b40bce59477beb5821170748e, with restored '\0' at the end of buffer name.

Differential Revision: https://reviews.llvm.org/D138555
llvm/lib/Support/MemoryBuffer.cpp