-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a new
URI::rebase
method (#1512)
Signed-off-by: Juan Cruz Viotti <[email protected]>
- Loading branch information
Showing
4 changed files
with
75 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#include <gtest/gtest.h> | ||
|
||
#include <sourcemeta/core/uri.h> | ||
|
||
TEST(URI_rebase, absolute_to_relative_match) { | ||
sourcemeta::core::URI uri{"https://example.com/foo/bar/baz"}; | ||
const sourcemeta::core::URI base{"https://example.com/foo"}; | ||
const sourcemeta::core::URI new_base{"/qux"}; | ||
uri.rebase(base, new_base); | ||
EXPECT_EQ(uri.recompose(), "/qux/bar/baz"); | ||
} | ||
|
||
TEST(URI_rebase, absolute_to_relative_mismatch) { | ||
sourcemeta::core::URI uri{"https://example.com/foo/bar/baz"}; | ||
const sourcemeta::core::URI base{"https://another.com/test"}; | ||
const sourcemeta::core::URI new_base{"/qux"}; | ||
uri.rebase(base, new_base); | ||
EXPECT_EQ(uri.recompose(), "https://example.com/foo/bar/baz"); | ||
} | ||
|
||
TEST(URI_rebase, absolute_to_relative_equal) { | ||
sourcemeta::core::URI uri{"https://example.com/foo/bar/baz"}; | ||
const sourcemeta::core::URI base{"https://example.com/foo/bar/baz"}; | ||
const sourcemeta::core::URI new_base{"/qux"}; | ||
uri.rebase(base, new_base); | ||
EXPECT_EQ(uri.recompose(), "/qux"); | ||
} |
0204113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark (macos/llvm)
Regex_Lower_S_Or_Upper_S_Asterisk
2.40528949223717
ns/iter1.6132219264261654
ns/iter1.49
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar
2.1010753595790823
ns/iter1.62865865887365
ns/iter1.29
Regex_Period_Asterisk
2.1022324273070314
ns/iter1.592038192279076
ns/iter1.32
Regex_Group_Period_Asterisk_Group
2.277073569655098
ns/iter1.6023101441047511
ns/iter1.42
Regex_Period_Plus
2.6179839876608964
ns/iter1.9092907306498474
ns/iter1.37
Regex_Period
2.249626963925015
ns/iter1.9109323981106034
ns/iter1.18
Regex_Caret_Period_Plus_Dollar
2.3424810738343758
ns/iter1.9063061258617937
ns/iter1.23
Regex_Caret_Group_Period_Plus_Group_Dollar
2.825780301767074
ns/iter1.948605287084221
ns/iter1.45
Regex_Caret_Period_Asterisk_Dollar
2.4141685558597996
ns/iter1.6302195279847143
ns/iter1.48
Regex_Caret_Group_Period_Asterisk_Group_Dollar
2.311167324375198
ns/iter1.6708929359523077
ns/iter1.38
Regex_Caret_X_Hyphen
8.268186254546137
ns/iter6.668508113499011
ns/iter1.24
Regex_Period_Md_Dollar
90.77960228045144
ns/iter72.07243247022359
ns/iter1.26
Regex_Caret_Slash_Period_Asterisk
6.922445528292117
ns/iter5.112888803292077
ns/iter1.35
Regex_Caret_Period_Range_Dollar
3.1230026097978594
ns/iter2.402459608512268
ns/iter1.30
Regex_Nested_Backtrack
1100.3113091607884
ns/iter767.1767151160252
ns/iter1.43
JSON_Array_Of_Objects_Unique
445.1362971572662
ns/iter337.7685618266326
ns/iter1.32
JSON_Parse_1
30737.690785178576
ns/iter21847.69699413882
ns/iter1.41
JSON_Fast_Hash_Helm_Chart_Lock
71.98867151722295
ns/iter48.81202448491157
ns/iter1.47
JSON_Equality_Helm_Chart_Lock
181.84870052571904
ns/iter122.34174422804305
ns/iter1.49
JSON_String_Equal/10
10.816496818552835
ns/iter7.626710759150559
ns/iter1.42
JSON_String_Equal/100
8.130422814533588
ns/iter6.1449219527109555
ns/iter1.32
JSON_String_Equal_Small_By_Perfect_Hash/10
0.39599403970443975
ns/iter0.32136900953678493
ns/iter1.23
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10
3.7685585760553497
ns/iter3.0871657954181946
ns/iter1.22
JSON_String_Fast_Hash/10
2.1767626683963863
ns/iter1.6511864788861732
ns/iter1.32
JSON_String_Fast_Hash/100
2.395204551711763
ns/iter1.9217824713236666
ns/iter1.25
JSON_String_Key_Hash/10
1.692902847516392
ns/iter1.2959113235136792
ns/iter1.31
JSON_String_Key_Hash/100
1.7640515009134172
ns/iter1.2956803263040384
ns/iter1.36
JSON_Object_Defines_Miss_Same_Length
2.7454944941331045
ns/iter2.24713382564254
ns/iter1.22
JSON_Object_Defines_Miss_Too_Small
2.7825303138383943
ns/iter2.266169563375415
ns/iter1.23
JSON_Object_Defines_Miss_Too_Large
2.6836957425825463
ns/iter2.259714165855326
ns/iter1.19
Pointer_Object_Traverse
29.41010936870542
ns/iter17.284188800450774
ns/iter1.70
Pointer_Object_Try_Traverse
28.353831962054223
ns/iter22.241601129791892
ns/iter1.27
Pointer_Push_Back_Pointer_To_Weak_Pointer
232.66725631368473
ns/iter172.14661983129048
ns/iter1.35
This comment was automatically generated by workflow using github-action-benchmark.
0204113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark (linux/llvm)
Regex_Lower_S_Or_Upper_S_Asterisk
2.21986859531364
ns/iter2.2149192883381406
ns/iter1.00
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar
2.1791113724026356
ns/iter2.2278377711646424
ns/iter0.98
Regex_Period_Asterisk
2.1836536498130132
ns/iter2.2045383462973294
ns/iter0.99
Regex_Group_Period_Asterisk_Group
2.1798587237339486
ns/iter2.2271069193108604
ns/iter0.98
Regex_Period_Plus
2.4865524732996733
ns/iter2.796657471234095
ns/iter0.89
Regex_Period
2.4862937492451205
ns/iter2.52091532562572
ns/iter0.99
Regex_Caret_Period_Plus_Dollar
2.486509895828284
ns/iter2.486391235489686
ns/iter1.00
Regex_Caret_Group_Period_Plus_Group_Dollar
2.486029122155151
ns/iter2.4899976537769306
ns/iter1.00
Regex_Caret_Period_Asterisk_Dollar
2.192333155056611
ns/iter2.486749510911046
ns/iter0.88
Regex_Caret_Group_Period_Asterisk_Group_Dollar
2.1859769707239756
ns/iter2.488192848254724
ns/iter0.88
Regex_Caret_X_Hyphen
12.51904500003585
ns/iter12.544773097899597
ns/iter1.00
Regex_Period_Md_Dollar
81.33361760616131
ns/iter81.43376532458123
ns/iter1.00
Regex_Caret_Slash_Period_Asterisk
5.902911237214954
ns/iter6.120749177551043
ns/iter0.96
Regex_Caret_Period_Range_Dollar
4.042315002427575
ns/iter4.042899854338092
ns/iter1.00
Regex_Nested_Backtrack
516.0803699999974
ns/iter489.8854838813028
ns/iter1.05
JSON_Array_Of_Objects_Unique
407.5347936846079
ns/iter406.91847579404254
ns/iter1.00
JSON_Parse_1
30617.8600147948
ns/iter30488.781807638275
ns/iter1.00
JSON_Fast_Hash_Helm_Chart_Lock
59.25027570861468
ns/iter59.75723166907586
ns/iter0.99
JSON_Equality_Helm_Chart_Lock
159.28874627870363
ns/iter151.13803946511163
ns/iter1.05
JSON_String_Equal/10
7.771790345597506
ns/iter6.254851828174069
ns/iter1.24
JSON_String_Equal/100
8.09105473020457
ns/iter6.898175271452233
ns/iter1.17
JSON_String_Equal_Small_By_Perfect_Hash/10
0.9345603668633746
ns/iter0.9349128745631464
ns/iter1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10
10.256879956541114
ns/iter14.59806438072399
ns/iter0.70
JSON_String_Fast_Hash/10
2.4885502833624558
ns/iter2.4894280418100436
ns/iter1.00
JSON_String_Fast_Hash/100
2.486020017164823
ns/iter2.48591011974145
ns/iter1.00
JSON_String_Key_Hash/10
2.227541274483755
ns/iter2.691225684326004
ns/iter0.83
JSON_String_Key_Hash/100
1.8691706961813093
ns/iter1.8662058157310295
ns/iter1.00
JSON_Object_Defines_Miss_Same_Length
3.7391244571419975
ns/iter3.738323205761038
ns/iter1.00
JSON_Object_Defines_Miss_Too_Small
3.7411910630330603
ns/iter3.7404648203799997
ns/iter1.00
JSON_Object_Defines_Miss_Too_Large
3.740703429573011
ns/iter3.734676533248378
ns/iter1.00
Pointer_Object_Traverse
45.86531325778706
ns/iter44.38559942634216
ns/iter1.03
Pointer_Object_Try_Traverse
52.32695454645684
ns/iter52.27130399918846
ns/iter1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer
353.9687046292951
ns/iter307.8820744232105
ns/iter1.15
This comment was automatically generated by workflow using github-action-benchmark.
0204113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark (windows/msvc)
Regex_Lower_S_Or_Upper_S_Asterisk
6.918552455358805
ns/iter6.897590401785233
ns/iter1.00
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar
7.153497767856518
ns/iter6.955555357143745
ns/iter1.03
Regex_Period_Asterisk
6.855547737252702
ns/iter6.908341517858827
ns/iter0.99
Regex_Group_Period_Asterisk_Group
7.094109374999086
ns/iter7.007477678571763
ns/iter1.01
Regex_Period_Plus
7.569462053572198
ns/iter7.465551339286439
ns/iter1.01
Regex_Period
7.1607615751773706
ns/iter7.381071395618279
ns/iter0.97
Regex_Caret_Period_Plus_Dollar
7.364873214285694
ns/iter7.371216517856485
ns/iter1.00
Regex_Caret_Group_Period_Plus_Group_Dollar
7.746556919643004
ns/iter7.666034598215227
ns/iter1.01
Regex_Caret_Period_Asterisk_Dollar
7.143938616070195
ns/iter6.903112469182651
ns/iter1.03
Regex_Caret_Group_Period_Asterisk_Group_Dollar
7.1018917410725635
ns/iter6.892226562500119
ns/iter1.03
Regex_Caret_X_Hyphen
11.84594821428472
ns/iter14.253836320293052
ns/iter0.83
Regex_Period_Md_Dollar
152.39560267857095
ns/iter150.842464248127
ns/iter1.01
Regex_Caret_Slash_Period_Asterisk
10.417617187499673
ns/iter10.286482812499997
ns/iter1.01
Regex_Caret_Period_Range_Dollar
7.676850446427201
ns/iter7.466443080357266
ns/iter1.03
Regex_Nested_Backtrack
612.9008928569743
ns/iter608.1894000001284
ns/iter1.01
JSON_Array_Of_Objects_Unique
491.7552000001706
ns/iter489.0927031658577
ns/iter1.01
JSON_Parse_1
79747.20771391924
ns/iter79862.131696424
ns/iter1.00
JSON_Fast_Hash_Helm_Chart_Lock
64.3961071428529
ns/iter63.598901785724145
ns/iter1.01
JSON_Equality_Helm_Chart_Lock
188.57108533168898
ns/iter190.9624456216509
ns/iter0.99
JSON_String_Equal/10
9.055562906000413
ns/iter8.996712013409327
ns/iter1.01
JSON_String_Equal/100
9.95141406250255
ns/iter9.928766473534495
ns/iter1.00
JSON_String_Equal_Small_By_Perfect_Hash/10
2.168704687500167
ns/iter2.1707043749998434
ns/iter1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10
15.211705357143858
ns/iter15.057514408095356
ns/iter1.01
JSON_String_Fast_Hash/10
4.033113623273648
ns/iter4.033076480416005
ns/iter1.00
JSON_String_Fast_Hash/100
4.027788846478344
ns/iter4.035777462564652
ns/iter1.00
JSON_String_Key_Hash/10
7.807915143714567
ns/iter7.811377197270173
ns/iter1.00
JSON_String_Key_Hash/100
4.024014203614225
ns/iter4.0444973286517385
ns/iter0.99
JSON_Object_Defines_Miss_Same_Length
3.725400529061223
ns/iter3.7285199933408597
ns/iter1.00
JSON_Object_Defines_Miss_Too_Small
4.9573670000017955
ns/iter4.962575492179492
ns/iter1.00
JSON_Object_Defines_Miss_Too_Large
3.4062108867750145
ns/iter3.4284898153071324
ns/iter0.99
Pointer_Object_Traverse
50.198679999994056
ns/iter48.802676905331346
ns/iter1.03
Pointer_Object_Try_Traverse
67.84365178570998
ns/iter68.08651785714152
ns/iter1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer
179.58161693625948
ns/iter161.11787016411662
ns/iter1.11
This comment was automatically generated by workflow using github-action-benchmark.
0204113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark (macos/gcc)
Regex_Lower_S_Or_Upper_S_Asterisk
1.8842584735646382
ns/iter1.9545728162004088
ns/iter0.96
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar
1.8922256638546033
ns/iter1.915285261861305
ns/iter0.99
Regex_Period_Asterisk
1.8851627068668948
ns/iter1.8924581399868308
ns/iter1.00
Regex_Group_Period_Asterisk_Group
1.8816965590905295
ns/iter1.8938610132383853
ns/iter0.99
Regex_Period_Plus
1.5730677628124818
ns/iter1.9047222925579328
ns/iter0.83
Regex_Period
1.6243788883841455
ns/iter1.9072466962002732
ns/iter0.85
Regex_Caret_Period_Plus_Dollar
1.606879258388706
ns/iter1.9187974588903032
ns/iter0.84
Regex_Caret_Group_Period_Plus_Group_Dollar
1.606154747923962
ns/iter1.9094251696692368
ns/iter0.84
Regex_Caret_Period_Asterisk_Dollar
2.0461007890820166
ns/iter1.9339835786119668
ns/iter1.06
Regex_Caret_Group_Period_Asterisk_Group_Dollar
1.9261118606023913
ns/iter2.2925803865407643
ns/iter0.84
Regex_Caret_X_Hyphen
6.069722129086121
ns/iter6.124952991585372
ns/iter0.99
Regex_Period_Md_Dollar
72.73320001669275
ns/iter68.96130249492153
ns/iter1.05
Regex_Caret_Slash_Period_Asterisk
4.602272198797153
ns/iter4.448266748599201
ns/iter1.03
Regex_Caret_Period_Range_Dollar
1.8881345795359983
ns/iter1.9438410896439537
ns/iter0.97
Regex_Nested_Backtrack
814.743395535848
ns/iter823.2536066280511
ns/iter0.99
JSON_Array_Of_Objects_Unique
209.88632779878563
ns/iter212.8317046652063
ns/iter0.99
JSON_Parse_1
23102.044675125777
ns/iter23447.984281860627
ns/iter0.99
JSON_Fast_Hash_Helm_Chart_Lock
23.77156908596748
ns/iter23.534191331448497
ns/iter1.01
JSON_Equality_Helm_Chart_Lock
126.59933694956324
ns/iter115.05873759341422
ns/iter1.10
JSON_String_Equal/10
5.365191582379881
ns/iter5.733769571908107
ns/iter0.94
JSON_String_Equal/100
5.054135717233418
ns/iter5.430445681478728
ns/iter0.93
JSON_String_Equal_Small_By_Perfect_Hash/10
0.7446774539073732
ns/iter0.795870890036801
ns/iter0.94
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10
3.449735846810854
ns/iter3.503881812917075
ns/iter0.98
JSON_String_Fast_Hash/10
1.8929260373024552
ns/iter1.9161700820516099
ns/iter0.99
JSON_String_Fast_Hash/100
1.8917086117150954
ns/iter1.9247383176291506
ns/iter0.98
JSON_String_Key_Hash/10
1.4380577250658628
ns/iter1.4543259732370692
ns/iter0.99
JSON_String_Key_Hash/100
1.9659817285898
ns/iter1.934437870977794
ns/iter1.02
JSON_Object_Defines_Miss_Same_Length
1.7256799494108641
ns/iter1.7581643373149969
ns/iter0.98
JSON_Object_Defines_Miss_Too_Small
1.8859921347997552
ns/iter1.9229177365797465
ns/iter0.98
JSON_Object_Defines_Miss_Too_Large
1.727206263379654
ns/iter1.752470284966356
ns/iter0.99
Pointer_Object_Traverse
58.0782072746402
ns/iter56.08684450985707
ns/iter1.04
Pointer_Object_Try_Traverse
33.89767211560459
ns/iter38.1229252166395
ns/iter0.89
Pointer_Push_Back_Pointer_To_Weak_Pointer
155.50820584147908
ns/iter162.23391221895838
ns/iter0.96
This comment was automatically generated by workflow using github-action-benchmark.
0204113
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Benchmark (linux/gcc)
Pointer_Object_Traverse
45.71956643828084
ns/iter45.826712498255894
ns/iter1.00
Pointer_Object_Try_Traverse
26.230819232410663
ns/iter26.14608308080146
ns/iter1.00
Pointer_Push_Back_Pointer_To_Weak_Pointer
143.02938222374664
ns/iter145.21111672945935
ns/iter0.98
JSON_Array_Of_Objects_Unique
411.4672558743041
ns/iter409.9289689854521
ns/iter1.00
JSON_Parse_1
33144.2387918369
ns/iter33483.77904925706
ns/iter0.99
JSON_Fast_Hash_Helm_Chart_Lock
62.063919613319946
ns/iter62.774320197065556
ns/iter0.99
JSON_Equality_Helm_Chart_Lock
150.73609536574662
ns/iter149.34803021449997
ns/iter1.01
JSON_String_Equal/10
6.348699401445221
ns/iter6.339446156100262
ns/iter1.00
JSON_String_Equal/100
6.940789691962872
ns/iter6.961845521477361
ns/iter1.00
JSON_String_Equal_Small_By_Perfect_Hash/10
0.9356261160601498
ns/iter0.9357939077181391
ns/iter1.00
JSON_String_Equal_Small_By_Runtime_Perfect_Hash/10
14.289501268530168
ns/iter14.324747666855007
ns/iter1.00
JSON_String_Fast_Hash/10
0.9312233458793807
ns/iter0.934059813151016
ns/iter1.00
JSON_String_Fast_Hash/100
0.933555347146051
ns/iter0.9382954731616941
ns/iter0.99
JSON_String_Key_Hash/10
1.6675087108832194
ns/iter1.6720519019051263
ns/iter1.00
JSON_String_Key_Hash/100
1.9825329532282647
ns/iter1.9833938168696141
ns/iter1.00
JSON_Object_Defines_Miss_Same_Length
2.480507132585995
ns/iter2.4868816545084376
ns/iter1.00
JSON_Object_Defines_Miss_Too_Small
2.4902743915193675
ns/iter2.487559164888118
ns/iter1.00
JSON_Object_Defines_Miss_Too_Large
3.1041671168647356
ns/iter3.1083026123365882
ns/iter1.00
Regex_Lower_S_Or_Upper_S_Asterisk
3.4270651380193042
ns/iter3.4200216047681904
ns/iter1.00
Regex_Caret_Lower_S_Or_Upper_S_Asterisk_Dollar
3.384432558472978
ns/iter3.420324618534201
ns/iter0.99
Regex_Period_Asterisk
3.4156911345588914
ns/iter3.4221783359217475
ns/iter1.00
Regex_Group_Period_Asterisk_Group
3.388837303096848
ns/iter3.4248592289371818
ns/iter0.99
Regex_Period_Plus
3.7267397992338713
ns/iter3.7407009923171652
ns/iter1.00
Regex_Period
3.7127247471031084
ns/iter3.8460206149323177
ns/iter0.97
Regex_Caret_Period_Plus_Dollar
3.7385552315122257
ns/iter3.728649868930406
ns/iter1.00
Regex_Caret_Group_Period_Plus_Group_Dollar
3.7998269754375307
ns/iter3.7299037002839395
ns/iter1.02
Regex_Caret_Period_Asterisk_Dollar
4.644926304270539
ns/iter4.660616625146497
ns/iter1.00
Regex_Caret_Group_Period_Asterisk_Group_Dollar
4.672449920792929
ns/iter4.661854360740388
ns/iter1.00
Regex_Caret_X_Hyphen
12.391388297787923
ns/iter12.429927749345639
ns/iter1.00
Regex_Period_Md_Dollar
94.72973557323132
ns/iter96.46869161147598
ns/iter0.98
Regex_Caret_Slash_Period_Asterisk
8.076504261947115
ns/iter8.078988843716079
ns/iter1.00
Regex_Caret_Period_Range_Dollar
4.660969825525254
ns/iter4.662128751303857
ns/iter1.00
Regex_Nested_Backtrack
825.6401411006409
ns/iter860.7069801104158
ns/iter0.96
This comment was automatically generated by workflow using github-action-benchmark.