Skip to content

对 parseImpl 进行优化 #134

@Tangruilin

Description

@Tangruilin
sonic_force_inline void parseImpl(SAX &sax) {
#define sonic_check_err()     \
  do {                        \
    if (err_ != kErrorNone) { \
      goto err_invalid_char;  \
    }                         \
  } while (0)

    using namespace sonic_json::internal;
    // TODO (liuq19): vector is a temporary choice, will optimize in future.
    std::vector<uint32_t> depth;
    const uint32_t kArrMask = 1ull << 31;
    const uint32_t kObjMask = 0;
    bool found = true;

我这边注意到 parseImpl 中解析 json 字符串的时候使用的 depth 为堆变量.
我想我可以将这里修改为栈变量以获得一些性能提升. 同时补充一个简单的单元测试, 给出一个 json 解析的 baseline. 方便后续对 arm 下的性能优化.
拜托帮忙评估一下. @liuq19

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions