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:
Jeff Epler 2022-12-28 13:22:36 -06:00
parent 2c46e785f6
commit 7a005aa96b
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE

View File

@ -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)) { while (!is_eof(&active_file)) {
if (key_matches(&active_file, key)) { if (key_matches(&active_file, key)) {
result = read_value(&active_file, buf, quoted); result = read_value(&active_file, buf, quoted);
break;
} }
} }
close_file(&active_file); close_file(&active_file);