From 79a969cf3ac0451e6568391dfb81cb2003f21140 Mon Sep 17 00:00:00 2001 From: Benjamin Bannier Date: Mon, 20 Nov 2023 15:47:41 +0100 Subject: [PATCH] Reduce allocations in `Builder::startProfiler`. --- hilti/toolchain/include/ast/builder/builder.h | 2 +- hilti/toolchain/src/ast/builder/builder.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hilti/toolchain/include/ast/builder/builder.h b/hilti/toolchain/include/ast/builder/builder.h index 7b4905b09d..8532cf93b6 100644 --- a/hilti/toolchain/include/ast/builder/builder.h +++ b/hilti/toolchain/include/ast/builder/builder.h @@ -241,7 +241,7 @@ class Builder { bool empty() const { return _block.statements().empty() && _tmps.empty(); } - std::optional startProfiler(const std::string& name); + std::optional startProfiler(std::string_view name); void stopProfiler(Expression profiler); private: diff --git a/hilti/toolchain/src/ast/builder/builder.cc b/hilti/toolchain/src/ast/builder/builder.cc index 05c452f9b0..07f855c805 100644 --- a/hilti/toolchain/src/ast/builder/builder.cc +++ b/hilti/toolchain/src/ast/builder/builder.cc @@ -107,7 +107,7 @@ void Builder::setLocation(const Location& l) { _block._add(statement::SetLocation(builder::string_literal(l.render()))); } -std::optional Builder::startProfiler(const std::string& name) { +std::optional Builder::startProfiler(std::string_view name) { if ( ! context()->options().enable_profiling ) return {};