From 3f86f178a501dfb66ea65ce8e0fd2a097f32592f Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Sat, 8 Aug 2020 11:49:17 +0200 Subject: [PATCH] Use classic C string handling That way, we don't have to allocate memory, and it's also shorter. --- src/subprocess/process.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/subprocess/process.cpp b/src/subprocess/process.cpp index df1d9bf..cb23e63 100644 --- a/src/subprocess/process.cpp +++ b/src/subprocess/process.cpp @@ -177,9 +177,7 @@ std::vector process::make_env_vector_(const subprocess_env_map_t& env) { throw std::runtime_error{"no equal sign in environment variable"}; } - std::string existing_env_var_name{existing_env_var, 0, static_cast(equal_sign - existing_env_var)}; - - return existing_env_var_name == key; + return strncmp(existing_env_var, key.c_str(), equal_sign - existing_env_var) == 0; }; // delete existing env var, if any