-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(yaml): support collapsing of multiple anchor keys in step #391
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #391 +/- ##
==========================================
- Coverage 96.02% 95.99% -0.04%
==========================================
Files 69 69
Lines 5382 5440 +58
==========================================
+ Hits 5168 5222 +54
- Misses 138 140 +2
- Partials 76 78 +2
|
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.
looks like we essentially have same code in two places? should we create a helper function?
value := tmpService.Content[i+1] | ||
|
||
// check if key is an anchor reference | ||
if strings.EqualFold(key.Value, "<<") { |
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.
EqualFold() seems unnecessary here (and in the other location).
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.
if the equalfold is necessary you could use a switch case comparison for some extra speed
switch key.Value {
case "<<":
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.
i think it's a simple key.Value == "<<"
, no? there are no casing concerns.
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.
right, switch is faster tho (jump tables) but its negligible (with over 1 billion iterations it measures like 3% faster)
// iterate through map contents (key, value) | ||
for i := 0; i < len(tmpService.Content); i += 2 { | ||
key := tmpService.Content[i] | ||
value := tmpService.Content[i+1] |
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.
im assuming this cant panic? i couldnt get it to be nil while testing
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.
in the same spirit, the length is guaranteed to be an even number? (i think so?) :D
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.
Right I believe the map type check will always make this an even length
changing this to draft for now until we revisit |
#386 introduced a regression(?) where the following step configurations were no longer valid:
go-yaml
asserts that the proper usage of multiple anchors in a single map is to list them:Given how many current users leverage the first configuration, this PR aims to support that format even with the upgrade to go-yaml v3.