Skip to content

Commit 7a005aa

Browse files
committed
break out after reading the value
This is a small optimization, it avoids reading the full file when an early key is requested. In the case of an *invalid* TOML file such as ``` K=80 K=81 ``` this stops the value of K actually returned being 8081 and makes it 80 instead; but as it's a malformed file it doesn't really matter much.
1 parent 2c46e78 commit 7a005aa

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

shared-module/os/getenv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,7 @@ STATIC os_getenv_err_t os_getenv_vstr(const char *path, const char *key, vstr_t
292292
while (!is_eof(&active_file)) {
293293
if (key_matches(&active_file, key)) {
294294
result = read_value(&active_file, buf, quoted);
295+
break;
295296
}
296297
}
297298
close_file(&active_file);

0 commit comments

Comments
 (0)