Skip to content

Commit 2940701

Browse files
committed
feat: result pointer is now type JsonObject
1 parent 2b270ed commit 2940701

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

cpp_src/jsonparser.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ class StreamingJsonParser {
139139
}
140140
}
141141

142-
// TODO: don't use ::get
142+
// Don't confuse StreamingJsonParser::get and std::unqiue_ptr::get
143143
JsonObject* get() const {
144-
return dynamic_cast<JsonObject*>(result.get());
144+
return result.get();
145145
}
146146

147147
// Get the result as a Python dict
@@ -150,7 +150,7 @@ class StreamingJsonParser {
150150
}
151151

152152
private:
153-
std::unique_ptr<JsonValue> result;
153+
std::unique_ptr<JsonObject> result;
154154
// Holds a stack of pointers to JsonObjects, make sure that pointers pushed
155155
// here have lifetimes that exceed the time on stack.
156156
std::vector<JsonObject*> stack;
@@ -164,10 +164,8 @@ class StreamingJsonParser {
164164
}
165165

166166
void processChar(char c) {
167-
JsonObject* current_obj = stack.empty() ?
168-
dynamic_cast<JsonObject*>(result.get()) :
169-
stack.back();
170-
167+
JsonObject* current_obj = stack.empty() ? result.get() : stack.back();
168+
171169
switch (state) {
172170
case START:
173171
if (c == '{') {

0 commit comments

Comments
 (0)