aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/env.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-03-05 19:07:00 -0800
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2016-03-05 19:07:00 -0800
commita37d4d809e067e54dfaec74888bd668f1a1727d1 (patch)
treee15515a6865dfae9bddd8c5a98dcc0c56776fa07 /src/env.cpp
parent3044697baa8e098a31f8049194d7cf1890363cb2 (diff)
Save a few string allocations when importing environment variables
Diffstat (limited to 'src/env.cpp')
-rw-r--r--src/env.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/env.cpp b/src/env.cpp
index 28ea51b0..c24280bc 100644
--- a/src/env.cpp
+++ b/src/env.cpp
@@ -450,6 +450,7 @@ void env_init(const struct config_paths_t *paths /* or NULL */)
*/
/* Import environment variables. Walk backwards so that the first one out of any duplicates wins (#2784) */
+ wcstring key, val;
const char * const * envp = (environ ? environ : __environ);
size_t i = 0;
while (envp && envp[i])
@@ -468,9 +469,9 @@ void env_init(const struct config_paths_t *paths /* or NULL */)
}
else
{
- wcstring key = key_and_val.substr(0, eql);
+ key.assign(key_and_val, 0, eql);
if (is_read_only(key) || is_electric(key)) continue;
- wcstring val = key_and_val.substr(eql + 1);
+ val.assign(key_and_val, eql + 1, wcstring::npos);
if (variable_is_colon_delimited_array(key))
{
std::replace(val.begin(), val.end(), L':', ARRAY_SEP);