diff options
author | pennae <github@quasiparticle.net> | 2022-01-21 16:20:54 +0100 |
---|---|---|
committer | pennae <github@quasiparticle.net> | 2022-01-27 22:15:30 +0100 |
commit | d439dceb3bc47f10a6f1f5b8cf4a5b17adc80071 (patch) | |
tree | a856e03791017e24325813c8f48825f4bb827c80 /src/libexpr/flake/flake.cc | |
parent | 41d70a2fc8d243d8c83ecc1c9ba648b625957437 (diff) |
optionally return string_view from coerceToString
we'll retain the old coerceToString interface that returns a string, but callers
that don't need the returned value to outlive the Value it came from can save
copies by using the new interface instead. for values that weren't stringy we'll
pass a new buffer argument that'll be used for storage and shouldn't be
inspected.
Diffstat (limited to 'src/libexpr/flake/flake.cc')
-rw-r--r-- | src/libexpr/flake/flake.cc | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/libexpr/flake/flake.cc b/src/libexpr/flake/flake.cc index 809f54cc0..27ba3288b 100644 --- a/src/libexpr/flake/flake.cc +++ b/src/libexpr/flake/flake.cc @@ -253,7 +253,9 @@ static Flake getFlake( flake.config.settings.insert({setting.name, string(state.forceStringNoCtx(*setting.value, *setting.pos))}); else if (setting.value->type() == nPath) { PathSet emptyContext = {}; - flake.config.settings.insert({setting.name, state.coerceToString(*setting.pos, *setting.value, emptyContext, false, true, true)}); + flake.config.settings.emplace( + setting.name, + state.coerceToString(*setting.pos, *setting.value, emptyContext, false, true, true) .toOwned()); } else if (setting.value->type() == nInt) flake.config.settings.insert({setting.name, state.forceInt(*setting.value, *setting.pos)}); |