diff options
| author | jvoisin | 2022-05-03 00:12:47 +0200 |
|---|---|---|
| committer | jvoisin | 2022-05-03 00:12:47 +0200 |
| commit | 9b11f4105eacc2af8828b65fd946e2b584cdee7e (patch) | |
| tree | 1a774922f14680c83fc57fe26107d5eaf2809162 | |
| parent | 3132434447990f24516fb196b3fcf7771895a17b (diff) | |
Speed up a tiny bit `sp_parse_var`
| -rw-r--r-- | src/sp_var_parser.c | 6 | ||||
| -rw-r--r-- | src/sp_var_parser.h | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/src/sp_var_parser.c b/src/sp_var_parser.c index 2639991..e7ff766 100644 --- a/src/sp_var_parser.c +++ b/src/sp_var_parser.c | |||
| @@ -245,15 +245,15 @@ static sp_tree *parse_tokens(const char *restrict str, | |||
| 245 | } | 245 | } |
| 246 | 246 | ||
| 247 | sp_tree *sp_parse_var(const char *line) { | 247 | sp_tree *sp_parse_var(const char *line) { |
| 248 | sp_list_node *tokens_list = NULL; | 248 | static const sp_conf_token delimiter_list[] = { |
| 249 | sp_tree *tree = NULL; | ||
| 250 | const sp_conf_token delimiter_list[] = { | ||
| 251 | {.type = OBJECT, .text_repr = OBJECT_TOKEN}, | 249 | {.type = OBJECT, .text_repr = OBJECT_TOKEN}, |
| 252 | {.type = ARRAY, .text_repr = ARRAY_TOKEN}, | 250 | {.type = ARRAY, .text_repr = ARRAY_TOKEN}, |
| 253 | {.type = ARRAY_END, .text_repr = ARRAY_END_TOKEN}, | 251 | {.type = ARRAY_END, .text_repr = ARRAY_END_TOKEN}, |
| 254 | {.type = INTERPRETED_STRING, .text_repr = STRING_TOKEN}, | 252 | {.type = INTERPRETED_STRING, .text_repr = STRING_TOKEN}, |
| 255 | {.type = LITERAL_STRING, .text_repr = ESC_STRING_TOKEN}, | 253 | {.type = LITERAL_STRING, .text_repr = ESC_STRING_TOKEN}, |
| 256 | {.type = CLASS, .text_repr = CLASS_TOKEN}}; | 254 | {.type = CLASS, .text_repr = CLASS_TOKEN}}; |
| 255 | sp_list_node *tokens_list = NULL; | ||
| 256 | sp_tree *tree = NULL; | ||
| 257 | 257 | ||
| 258 | if (!line) { | 258 | if (!line) { |
| 259 | return NULL; | 259 | return NULL; |
diff --git a/src/sp_var_parser.h b/src/sp_var_parser.h index 6d53691..c2981a3 100644 --- a/src/sp_var_parser.h +++ b/src/sp_var_parser.h | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | typedef struct sp_token_s { | 5 | typedef struct sp_token_s { |
| 6 | elem_type type; | 6 | elem_type type; |
| 7 | char *text_repr; | 7 | const char *text_repr; |
| 8 | size_t pos; | 8 | size_t pos; |
| 9 | } sp_conf_token; | 9 | } sp_conf_token; |
| 10 | 10 | ||
