Repository: google/filament
File: libs/viewer/src/Settings.cpp (C++)

Code before:
        } else if (compare(tok, jsonChunk, "autoInstancingEnabled") == 0) {
             i = parse(tokens, i + 1, jsonChunk, &out->autoInstancingEnabled);
        } else if (compare(tok, jsonChunk, "autoScaleEnabled") == 0) {
             i = parse(tokens, i + 1, jsonChunk, &out->autoScaleEnabled);
        } else {
            slog.w << "Invalid viewer options key: '" << STR(tok, jsonChunk) << "'" << io::endl;
            i = parse(tokens, i + 1);
        }
        if (i < 0) {
            slog.e << "Invalid viewer options value: '" << STR(tok, jsonChunk) << "'" << io::endl;
            return i;
        }
    }
    return i;
}

static int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, DebugOptions* out) {
    CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
    int size = tokens[i++].size;
    for (int j = 0; j < size; ++j) {
        const jsmntok_t tok = tokens[i];
        CHECK_KEY(tok);
        if (compare(tok, jsonChunk, "skipFrames") == 0) {
            i = parse(tokens, i + 1, jsonChunk, &out->skipFrames);
        } else {
            slog.w << "Invalid viewer options key: '" << STR(tok, jsonChunk) << "'" << io::endl;
            i = parse(tokens, i + 1);
        }
        if (i < 0) {
            slog.e << "Invalid viewer options value: '" << STR(tok, jsonChunk) << "'" << io::endl;
            return i;
        }
    }
    return i;
}

int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, Settings* out) {
    CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
    int size = tokens[i++].size;
    for (int j = 0; j < size; ++j) {
        const jsmntok_t tok = tokens[i];
        CHECK_KEY(tok);
        if (compare(tok, jsonChunk, "view") == 0) {
            i = parse(tokens, i + 1, jsonChunk, &out->view);
        } else if (compare(tok, jsonChunk, "material") == 0) {
            i = parse(tokens, i + 1, jsonChunk, &out->material);
        } else if (compare(tok, jsonChunk, "lighting") == 0) {
            i = parse(tokens, i + 1, jsonChunk, &out->lighting);
        } else if (compare(tok, jsonChunk, "viewer") == 0) {
            i = parse(tokens, i + 1, jsonChunk, &out->viewer);
        } else if (compare(tok, jsonChunk, "debug") == 0) {

Review comment (bug):
```suggestion
            slog.w << "Invalid debug options key: '" << STR(tok, jsonChunk) << "'" << io::endl;
```

Code after:
        } else if (compare(tok, jsonChunk, "autoInstancingEnabled") == 0) {
             i = parse(tokens, i + 1, jsonChunk, &out->autoInstancingEnabled);
        } else if (compare(tok, jsonChunk, "autoScaleEnabled") == 0) {
             i = parse(tokens, i + 1, jsonChunk, &out->autoScaleEnabled);
        } else {
            slog.w << "Invalid viewer options key: '" << STR(tok, jsonChunk) << "'" << io::endl;
            i = parse(tokens, i + 1);
        }
        if (i < 0) {
            slog.e << "Invalid viewer options value: '" << STR(tok, jsonChunk) << "'" << io::endl;
            return i;
        }
    }
    return i;
}

static int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, DebugOptions* out) {
    CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
    int size = tokens[i++].size;
    for (int j = 0; j < size; ++j) {
        const jsmntok_t tok = tokens[i];
        CHECK_KEY(tok);
        if (compare(tok, jsonChunk, "skipFrames") == 0) {
            i = parse(tokens, i + 1, jsonChunk, &out->skipFrames);
        } else {
            slog.w << "Invalid debug options key: '" << STR(tok, jsonChunk) << "'" << io::endl;
            i = parse(tokens, i + 1);
        }
        if (i < 0) {
            slog.e << "Invalid debug options value: '" << STR(tok, jsonChunk) << "'" << io::endl;
            return i;
        }
    }
    return i;
}

int parse(jsmntok_t const* tokens, int i, const char* jsonChunk, Settings* out) {
    CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
    int size = tokens[i++].size;
    for (int j = 0; j < size; ++j) {
        const jsmntok_t tok = tokens[i];
        CHECK_KEY(tok);
        if (compare(tok, jsonChunk, "view") == 0) {
            i = parse(tokens, i + 1, jsonChunk, &out->view);
        } else if (compare(tok, jsonChunk, "material") == 0) {
            i = parse(tokens, i + 1, jsonChunk, &out->material);
        } else if (compare(tok, jsonChunk, "lighting") == 0) {
            i = parse(tokens, i + 1, jsonChunk, &out->lighting);
        } else if (compare(tok, jsonChunk, "viewer") == 0) {
            i = parse(tokens, i + 1, jsonChunk, &out->viewer);
        } else if (compare(tok, jsonChunk, "debug") == 0) {