Skip to content

Commit

Permalink
Cleanup various JSON-related TODOs (#1412)
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
  • Loading branch information
jviotti authored Jan 1, 2025
1 parent 5963014 commit e3d4f14
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 6 deletions.
3 changes: 0 additions & 3 deletions src/json/include/sourcemeta/jsontoolkit/json_flat_map.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

namespace sourcemeta::jsontoolkit {

// TODO: Merge as part of JSONObject
/// @ingroup json
template <typename Key, typename Value, typename Hash> class FlatMap {
public:
Expand Down Expand Up @@ -53,8 +52,6 @@ template <typename Key, typename Value, typename Hash> class FlatMap {
return this->hasher(key);
}

// TODO: Add an assign overload for const key, rvalue

auto assign(key_type &&key, mapped_type &&value) -> hash_type {
const auto key_hash{this->hash(key)};

Expand Down
3 changes: 2 additions & 1 deletion src/json/json_value.cc
Original file line number Diff line number Diff line change
Expand Up @@ -587,7 +587,8 @@ JSON::at(const String &key,
} else if (this->is_boolean()) {
return sizeof(bool);
} else {
return sizeof(std::nullptr_t);
// The size of the union
return 8;
}
}

Expand Down
2 changes: 0 additions & 2 deletions test/json/json_null_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ TEST(JSON_null, literal_equality) {

TEST(JSON_null, estimated_byte_size) {
const sourcemeta::jsontoolkit::JSON document{nullptr};
// TODO: Use a different internal type for representing nulls,
// as this is otherwise 64 bytes?
EXPECT_EQ(document.estimated_byte_size(), 8);
}

Expand Down

4 comments on commit e3d4f14

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (linux/llvm)

Benchmark suite Current: e3d4f14 Previous: 5963014 Ratio
JSON_Array_Of_Objects_Unique 437.71626443914045 ns/iter 433.7037255995188 ns/iter 1.01
JSON_Parse_1 32074.64251607191 ns/iter 30470.609515571632 ns/iter 1.05
JSON_Fast_Hash_Helm_Chart_Lock 62.227064830337405 ns/iter 54.71379696841756 ns/iter 1.14
JSON_Equality_Helm_Chart_Lock 151.71289603815802 ns/iter 149.74776291529548 ns/iter 1.01
Regex_Lower_S_Or_Upper_S_Asterisk 2.2099609465997734 ns/iter 2.2090531148396537 ns/iter 1.00
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 2.201903645447679 ns/iter 2.198717157599572 ns/iter 1.00
Regex_Period_Asterisk 2.2027075997977814 ns/iter 2.2415224388724657 ns/iter 0.98
Regex_Group_Period_Asterisk_Group 2.2030467758563295 ns/iter 2.209087334563145 ns/iter 1.00
Regex_Period_Plus 2.488285031623421 ns/iter 2.264504907085548 ns/iter 1.10
Regex_Period 2.4862767005306874 ns/iter 2.2661807785091876 ns/iter 1.10
Regex_Caret_Period_Plus_Dollar 2.4870033898974846 ns/iter 2.2900163949438666 ns/iter 1.09
Regex_Caret_Group_Period_Plus_Group_Dollar 2.49093211272742 ns/iter 2.2581670134221365 ns/iter 1.10
Regex_Caret_Period_Asterisk_Dollar 3.4219833621083935 ns/iter 2.4855196455628374 ns/iter 1.38
Regex_Caret_Group_Period_Asterisk_Group_Dollar 2.202550256108647 ns/iter 2.486032482244995 ns/iter 0.89
Regex_Caret_X_Hyphen 12.565605392116515 ns/iter 13.050591816284541 ns/iter 0.96
Regex_Period_Md_Dollar 73.55546144623383 ns/iter 73.40507290563339 ns/iter 1.00
Regex_Caret_Slash_Period_Asterisk 6.216454784509748 ns/iter 7.146390469841245 ns/iter 0.87
Regex_Caret_Period_Range_Dollar 2.9760744550740563 ns/iter 3.733886117683477 ns/iter 0.80
Regex_Nested_Backtrack 501.3591780000297 ns/iter 491.81989543446633 ns/iter 1.02
Pointer_Object_Traverse 44.84968504844869 ns/iter 44.80996494950291 ns/iter 1.00
Pointer_Object_Try_Traverse 52.27804925625326 ns/iter 52.33541029814524 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 352.0166325683418 ns/iter 351.95318555195104 ns/iter 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (macos/llvm)

Benchmark suite Current: e3d4f14 Previous: 5963014 Ratio
JSON_Array_Of_Objects_Unique 330.4494081448484 ns/iter 328.7267695892752 ns/iter 1.01
JSON_Parse_1 21701.9645974385 ns/iter 21292.337370297195 ns/iter 1.02
JSON_Fast_Hash_Helm_Chart_Lock 47.91071306058982 ns/iter 47.61294333670944 ns/iter 1.01
JSON_Equality_Helm_Chart_Lock 137.82648579957984 ns/iter 137.7435427643075 ns/iter 1.00
Regex_Lower_S_Or_Upper_S_Asterisk 1.5677847860591951 ns/iter 1.599622127042629 ns/iter 0.98
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 1.5731284133782364 ns/iter 1.58004025719433 ns/iter 1.00
Regex_Period_Asterisk 1.565905254693926 ns/iter 1.566025773481556 ns/iter 1.00
Regex_Group_Period_Asterisk_Group 1.5674464592186697 ns/iter 1.5746262657211485 ns/iter 1.00
Regex_Period_Plus 1.8810559159476816 ns/iter 1.9046978953949203 ns/iter 0.99
Regex_Period 1.881875528745847 ns/iter 1.8897144905639562 ns/iter 1.00
Regex_Caret_Period_Plus_Dollar 1.8833519950988238 ns/iter 1.8849254049980002 ns/iter 1.00
Regex_Caret_Group_Period_Plus_Group_Dollar 1.8973286351646121 ns/iter 1.8841303243544167 ns/iter 1.01
Regex_Caret_Period_Asterisk_Dollar 1.5818838456824291 ns/iter 1.5880316528374685 ns/iter 1.00
Regex_Caret_Group_Period_Asterisk_Group_Dollar 1.5641900362520544 ns/iter 1.579877152508117 ns/iter 0.99
Regex_Caret_X_Hyphen 6.297649634070122 ns/iter 6.2689368658059115 ns/iter 1.00
Regex_Period_Md_Dollar 67.48247672645114 ns/iter 68.54769803767255 ns/iter 0.98
Regex_Caret_Slash_Period_Asterisk 5.965427127926755 ns/iter 6.015211279027055 ns/iter 0.99
Regex_Caret_Period_Range_Dollar 2.03782609407208 ns/iter 2.15596919842569 ns/iter 0.95
Regex_Nested_Backtrack 732.6036863947397 ns/iter 755.5894716344942 ns/iter 0.97
Pointer_Object_Traverse 14.76069013929599 ns/iter 15.18080789096482 ns/iter 0.97
Pointer_Object_Try_Traverse 31.307038352336704 ns/iter 35.076390885323725 ns/iter 0.89
Pointer_Push_Back_Pointer_To_Weak_Pointer 172.50862811650057 ns/iter 199.00267190890156 ns/iter 0.87

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (linux/gcc)

Benchmark suite Current: e3d4f14 Previous: 5963014 Ratio
Pointer_Object_Traverse 43.8938553628957 ns/iter 45.29239252253465 ns/iter 0.97
Pointer_Object_Try_Traverse 22.464979118431287 ns/iter 22.43294769152697 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 213.2510941883446 ns/iter 217.46715785976602 ns/iter 0.98
Regex_Lower_S_Or_Upper_S_Asterisk 3.221349417382267 ns/iter 2.489574018758489 ns/iter 1.29
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 3.166731024562928 ns/iter 2.4895833414702384 ns/iter 1.27
Regex_Period_Asterisk 3.1476046160116873 ns/iter 2.4898456894713563 ns/iter 1.26
Regex_Group_Period_Asterisk_Group 3.1452689074763334 ns/iter 2.4883906571760352 ns/iter 1.26
Regex_Period_Plus 3.13354708986803 ns/iter 2.7989118544028413 ns/iter 1.12
Regex_Period 3.2366515618481935 ns/iter 2.799039121071779 ns/iter 1.16
Regex_Caret_Period_Plus_Dollar 3.2392018040159503 ns/iter 2.8190237582885573 ns/iter 1.15
Regex_Caret_Group_Period_Plus_Group_Dollar 3.200302142985193 ns/iter 2.7991641751973875 ns/iter 1.14
Regex_Caret_Period_Asterisk_Dollar 3.7268628517323394 ns/iter 3.729620384303959 ns/iter 1.00
Regex_Caret_Group_Period_Asterisk_Group_Dollar 3.7268774419745183 ns/iter 3.727667347763939 ns/iter 1.00
Regex_Caret_X_Hyphen 12.425781608117006 ns/iter 13.052552235091053 ns/iter 0.95
Regex_Period_Md_Dollar 89.08450340373336 ns/iter 88.78697800024537 ns/iter 1.00
Regex_Caret_Slash_Period_Asterisk 7.150290633605439 ns/iter 7.1485959803585555 ns/iter 1.00
Regex_Caret_Period_Range_Dollar 4.042004651659798 ns/iter 4.038826515682858 ns/iter 1.00
Regex_Nested_Backtrack 813.4009478738701 ns/iter 844.9125630286859 ns/iter 0.96
JSON_Array_Of_Objects_Unique 380.3190096905847 ns/iter 379.75674740392515 ns/iter 1.00
JSON_Parse_1 32668.460258865216 ns/iter 33076.53822644617 ns/iter 0.99
JSON_Fast_Hash_Helm_Chart_Lock 62.929597923582065 ns/iter 62.60602883091171 ns/iter 1.01
JSON_Equality_Helm_Chart_Lock 143.29627354241185 ns/iter 143.03804187071788 ns/iter 1.00

This comment was automatically generated by workflow using github-action-benchmark.

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark (windows/msvc)

Benchmark suite Current: e3d4f14 Previous: 5963014 Ratio
JSON_Array_Of_Objects_Unique 418.81653195799527 ns/iter 423.07011744403707 ns/iter 0.99
JSON_Parse_1 82376.81799919019 ns/iter 81744.6986607097 ns/iter 1.01
JSON_Fast_Hash_Helm_Chart_Lock 53.51917857142651 ns/iter 54.40115999999762 ns/iter 0.98
JSON_Equality_Helm_Chart_Lock 219.02413531141934 ns/iter 220.1759687500271 ns/iter 0.99
Regex_Lower_S_Or_Upper_S_Asterisk 8.183487500000197 ns/iter 8.148405767192235 ns/iter 1.00
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar 7.996433000016435 ns/iter 9.678378974649238 ns/iter 0.83
Regex_Period_Asterisk 7.764679687500831 ns/iter 8.37955174830778 ns/iter 0.93
Regex_Group_Period_Asterisk_Group 8.16469282069353 ns/iter 7.840765143566587 ns/iter 1.04
Regex_Period_Plus 7.937702643134225 ns/iter 8.07170085682052 ns/iter 0.98
Regex_Period 8.044958705357073 ns/iter 7.849518714957124 ns/iter 1.02
Regex_Caret_Period_Plus_Dollar 7.933171874999597 ns/iter 8.186675856308684 ns/iter 0.97
Regex_Caret_Group_Period_Plus_Group_Dollar 8.095683446000894 ns/iter 8.447953087284594 ns/iter 0.96
Regex_Caret_Period_Asterisk_Dollar 8.156839249298837 ns/iter 7.787190848212841 ns/iter 1.05
Regex_Caret_Group_Period_Asterisk_Group_Dollar 8.844378124999608 ns/iter 7.823330322216322 ns/iter 1.13
Regex_Caret_X_Hyphen 11.694298437500805 ns/iter 11.846024947116497 ns/iter 0.99
Regex_Period_Md_Dollar 148.1656473214394 ns/iter 141.64836197998318 ns/iter 1.05
Regex_Caret_Slash_Period_Asterisk 11.745619642856095 ns/iter 11.970194812631393 ns/iter 0.98
Regex_Caret_Period_Range_Dollar 8.984697281318923 ns/iter 8.955088352880434 ns/iter 1.00
Regex_Nested_Backtrack 592.1585714286185 ns/iter 594.5483928570638 ns/iter 1.00
Pointer_Object_Traverse 56.27767857142934 ns/iter 55.947100000003054 ns/iter 1.01
Pointer_Object_Try_Traverse 75.87578124999946 ns/iter 75.75494419642988 ns/iter 1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer 174.43887105616898 ns/iter 174.6806500901897 ns/iter 1.00

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.