Performance: improve getenv
@@ -1640,8 +1640,9 @@ char* codes_getenv(const char* name)
{
/* Look for the new ecCodes environment variable names */
/* if not found, then look for old grib_api ones for backward compatibility */
+ char* result = getenv(name);
+ if (result == NULL) {
const char* old_name = name;
- char* result = NULL;
/* Test the most commonly used variables first */
if (STR_EQ(name, "ECCODES_SAMPLES_PATH")) old_name="GRIB_SAMPLES_PATH";
@@ -1665,8 +1666,6 @@ char* codes_getenv(const char* name)
else if (STR_EQ(name, "ECCODES_GRIB_DUMP_JPG_FILE")) old_name="GRIB_DUMP_JPG_FILE";
else if (STR_EQ(name, "ECCODES_PRINT_MISSING")) old_name="GRIB_PRINT_MISSING";
- result = getenv(name);
- if (result == NULL) {
result = getenv(old_name);
}
return result;
