[clang] [clang-format][NFC] Replace a function with StringRef::contains (PR #146245)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 29 17:57:38 PDT 2025
owenca wrote:
> While it is less code, I find a bit harder to understand and the code gen is far worse: https://gcc.godbolt.org/z/KzG4YnTh3
`IsBlank` is misleading because of `std::isblank` whereas `Blanks.contains` is not, so the latter has better readability for me. As to the generated code, the latter is worse in runtime (IMO negligible in practice), but the code size is about the same with `-O2` and far better with `-Os` (again, negligible in practice). See [this](https://gcc.godbolt.org/z/YsaKa4hP7) modified example, which adds a call to the local function `IsBlank` to make the comparison fairer.
More importantly, we wouldn't need to update `IsBlank` if `Blanks` changes. This happened at least once (580da276161ee) before.
https://github.com/llvm/llvm-project/pull/146245
More information about the cfe-commits
mailing list