You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The changes in this commit involve using (gchar *) strings and some
dynamic allocation to make load_env_vars() easier to reason about.
Previously, we tried to be as efficient as possible by reading a line
into a buffer, iterating over it with multiple pointers, dividing
it into name and value by insertion of a null terminator, etc.
This is premature optimization. This function is not called along a path
of execution where performance is so critical as to require this. In my
opinion, clarity is more important.
* Use pcmk__scan_nvpair() to separate the line on the equal sign.
* Simplify name validation since we now have name as a separate string
(before the equal sign) and don't need to return first and last
pointers.
* Use an is_quoted boolean variable, so that we can limit the quote
character to the inner block and compare to the value instead of
maintaining a pointer to the quote character.
* Skip the leading quote by converting it to a space and calling
g_strchug() to memmove() value up by one position. This ensures that
value still points to the beginning of the buffer, which simplifies
freeing it later.
Signed-off-by: Reid Wahl <nrwahl@protonmail.com>
0 commit comments