Skip to content

Commit a03115a

Browse files
committed
Move end_scope to stage 2 code
1 parent 7219d28 commit a03115a

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

include/simdjson/document.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,8 +1041,6 @@ class parser {
10411041
really_inline bool on_number_s64(int64_t value) noexcept; ///< @private
10421042
really_inline bool on_number_u64(uint64_t value) noexcept; ///< @private
10431043
really_inline bool on_number_double(double value) noexcept; ///< @private
1044-
1045-
really_inline void end_scope(uint32_t start_tape_index, uint32_t count) noexcept; ///< @private
10461044
private:
10471045
/**
10481046
* The maximum document length this parser will automatically support.

src/document_parser_callbacks.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,6 @@ really_inline void parser::write_tape(uint64_t val, internal::tape_type t) noexc
113113
doc.tape[current_loc++] = val | ((uint64_t(char(t))) << 56);
114114
}
115115

116-
// this function is responsible for annotating the start of the scope
117-
really_inline void parser::end_scope(uint32_t start_tape_index, uint32_t count) noexcept {
118-
// count can overflow if it exceeds 24 bits... so we saturate
119-
// the convention being that a cnt of 0xffffff or more is undetermined in value (>= 0xffffff).
120-
const uint32_t cntsat = count > 0xFFFFFF ? 0xFFFFFF : count;
121-
// This is a load and an OR. It would be possible to just write once at doc.tape[d.tape_index]
122-
doc.tape[start_tape_index] |= current_loc | (uint64_t(cntsat) << 32);
123-
}
124-
125116
} // namespace simdjson
126117
} // namespace dom
127118

src/generic/stage2_build_tape.h

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,22 +152,33 @@ struct structural_parser {
152152
return depth >= doc_parser.max_depth();
153153
}
154154

155+
// this function is responsible for annotating the start of the scope
156+
really_inline void end_scope() noexcept {
157+
// count can overflow if it exceeds 24 bits... so we saturate
158+
// the convention being that a cnt of 0xffffff or more is undetermined in value (>= 0xffffff).
159+
const uint32_t start_tape_index = doc_parser.containing_scope[depth].tape_index;
160+
const uint32_t count = doc_parser.containing_scope[depth].count;
161+
const uint32_t cntsat = count > 0xFFFFFF ? 0xFFFFFF : count;
162+
// This is a load and an OR. It would be possible to just write once at doc.tape[d.tape_index]
163+
doc_parser.doc.tape[start_tape_index] |= doc_parser.current_loc | (uint64_t(cntsat) << 32);
164+
}
165+
155166
really_inline bool end_object() {
156167
depth--;
157168
doc_parser.on_end_object(doc_parser.containing_scope[depth].tape_index);
158-
doc_parser.end_scope(doc_parser.containing_scope[depth].tape_index, doc_parser.containing_scope[depth].count);
169+
end_scope();
159170
return false;
160171
}
161172
really_inline bool end_array() {
162173
depth--;
163174
doc_parser.on_end_array(doc_parser.containing_scope[depth].tape_index);
164-
doc_parser.end_scope(doc_parser.containing_scope[depth].tape_index, doc_parser.containing_scope[depth].count);
175+
end_scope();
165176
return false;
166177
}
167178
really_inline bool end_document() {
168179
depth--;
169180
doc_parser.on_end_document(doc_parser.containing_scope[depth].tape_index);
170-
doc_parser.end_scope(doc_parser.containing_scope[depth].tape_index, doc_parser.containing_scope[depth].count);
181+
end_scope();
171182
return false;
172183
}
173184

0 commit comments

Comments
 (0)