Commit a6b047a7 authored by Kamal Marhubi's avatar Kamal Marhubi

Replace string constants with kj::StringPtr

parent e9ca71c7
......@@ -393,9 +393,9 @@ public:
KJ_REQUIRE(!inputExhausted(), "JSON message ends prematurely.");
switch (nextChar()) {
case 'n': consume(NULL_); output.setNull(); break;
case 'f': consume(FALSE); output.setBoolean(false); break;
case 't': consume(TRUE); output.setBoolean(true); break;
case 'n': consume(kj::StringPtr("null")); output.setNull(); break;
case 'f': consume(kj::StringPtr("false")); output.setBoolean(false); break;
case 't': consume(kj::StringPtr("true")); output.setBoolean(true); break;
case '"': parseString(output); break;
case '[': parseArray(output); break;
case '{': parseObject(output); break;
......@@ -647,10 +647,6 @@ public:
}
private:
static const kj::ArrayPtr<const char> NULL_;
static const kj::ArrayPtr<const char> FALSE;
static const kj::ArrayPtr<const char> TRUE;
const size_t maxNestingDepth_;
const kj::ArrayPtr<const char> input_;
kj::ArrayPtr<const char> remaining_;
......@@ -658,22 +654,6 @@ private:
}; // class Parser
// clang warns about these constructors running on program start. All they do is each set a pointer
// and a size_t, so we politely ask clang to let it slide.
#ifdef __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wglobal-constructors"
#endif
// Array literal used instead of string literal to avoid null terminator.
const kj::ArrayPtr<const char> Parser::NULL_ = kj::ArrayPtr<const char>({'n','u','l','l'});
const kj::ArrayPtr<const char> Parser::FALSE = kj::ArrayPtr<const char>({'f','a','l','s','e'});
const kj::ArrayPtr<const char> Parser::TRUE = kj::ArrayPtr<const char>({'t','r','u','e'});
#ifdef __clang__
#pragma clang diagnostic pop
#endif
} // namespace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment