Skip to content

Commit 0a265e7

Browse files
committed
Remove debug log and add a comment
1 parent 7f30c01 commit 0a265e7

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

mongoose.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2563,10 +2563,13 @@ int mg_json_get(struct mg_str json, const char *path, int *toklen) {
25632563
case S_KEY:
25642564
if (c == '"') {
25652565
int n = mg_pass_string(&s[i + 1], len - i - 1);
2566-
printf("K %s %d %d %d [%.*s]\n", path, pos, n, i, n + 2, s + i);
2566+
// printf("K %s %d %d %d [%.*s]\n", path, pos, n, i, n + 2, s + i);
25672567
if (n < 0) return n;
25682568
if (i + 1 + n >= len) return MG_JSON_NOT_FOUND;
2569-
printf("K %s [%.*s] %d %d %d\n", path, n, &s[i + 1], n, depth, ed);
2569+
// printf("K %s [%.*s] %d %d %d\n", path, n, &s[i + 1], n, depth, ed);
2570+
// NOTE(cpq): in the check sequence below is important.
2571+
// strncmp() must go first: it fails fast if the remaining length of
2572+
// the path is smaller than `n`.
25702573
if (depth == ed && path[pos - 1] == '.' &&
25712574
strncmp(&s[i + 1], &path[pos], (size_t) n) == 0 &&
25722575
(path[pos + n] == '\0' || path[pos + n] == '.' ||

src/json.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,10 +167,13 @@ int mg_json_get(struct mg_str json, const char *path, int *toklen) {
167167
case S_KEY:
168168
if (c == '"') {
169169
int n = mg_pass_string(&s[i + 1], len - i - 1);
170-
printf("K %s %d %d %d [%.*s]\n", path, pos, n, i, n + 2, s + i);
170+
// printf("K %s %d %d %d [%.*s]\n", path, pos, n, i, n + 2, s + i);
171171
if (n < 0) return n;
172172
if (i + 1 + n >= len) return MG_JSON_NOT_FOUND;
173-
printf("K %s [%.*s] %d %d %d\n", path, n, &s[i + 1], n, depth, ed);
173+
// printf("K %s [%.*s] %d %d %d\n", path, n, &s[i + 1], n, depth, ed);
174+
// NOTE(cpq): in the check sequence below is important.
175+
// strncmp() must go first: it fails fast if the remaining length of
176+
// the path is smaller than `n`.
174177
if (depth == ed && path[pos - 1] == '.' &&
175178
strncmp(&s[i + 1], &path[pos], (size_t) n) == 0 &&
176179
(path[pos + n] == '\0' || path[pos + n] == '.' ||

0 commit comments

Comments
 (0)