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.
This commit is contained in:
parent
2c46e785f6
commit
7a005aa96b
@ -292,6 +292,7 @@ STATIC os_getenv_err_t os_getenv_vstr(const char *path, const char *key, vstr_t
|
||||
while (!is_eof(&active_file)) {
|
||||
if (key_matches(&active_file, key)) {
|
||||
result = read_value(&active_file, buf, quoted);
|
||||
break;
|
||||
}
|
||||
}
|
||||
close_file(&active_file);
|
||||
|
Loading…
Reference in New Issue
Block a user