-
Notifications
You must be signed in to change notification settings - Fork 207
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
Some small optimisations #3261
Open
peterebden
wants to merge
5
commits into
thought-machine:master
Choose a base branch
from
peterebden:moar-providefor
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Some small optimisations #3261
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -108,10 +108,19 @@ func resolvePluginValue(values []string, subrepo string) []string { | |
continue // I guess it wasn't a build label. Leave it alone. | ||
} | ||
// Force the full build label including empty subrepo so this is portable | ||
v = fmt.Sprintf("///%v//%v:%v", l.Subrepo, l.PackageName, l.Name) | ||
var buf strings.Builder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Add a comment here (or at the top of the file) to explain why you're not using fmt.Sprintf |
||
buf.Grow(len(l.Subrepo) + len(l.PackageName) + len(l.Name) + len(annotation) + 7) // +7 for the delimiters | ||
buf.WriteString("///") | ||
buf.WriteString(l.Subrepo) | ||
buf.WriteString("//") | ||
buf.WriteString(l.PackageName) | ||
buf.WriteByte(':') | ||
buf.WriteString(l.Name) | ||
if annotation != "" { | ||
v = fmt.Sprintf("%v|%v", v, annotation) | ||
buf.WriteByte('|') | ||
buf.WriteString(annotation) | ||
} | ||
v = buf.String() | ||
} | ||
ret[i] = v | ||
} | ||
|
@@ -155,7 +164,7 @@ func pluginConfig(pluginState *core.BuildState, pkgState *core.BuildState) pyDic | |
continue | ||
} | ||
|
||
fullConfigKey := fmt.Sprintf("%v.%v", pluginName, configKey) | ||
fullConfigKey := pluginName + "." + configKey | ||
value, ok := extraVals[strings.ToLower(configKey)] | ||
if !ok { | ||
// The default values are defined in the subrepo so should be parsed in that scope | ||
|
@@ -230,9 +239,9 @@ func toPyObject(key, val, toType string, optional bool) pyObject { | |
case "bool": | ||
switch strings.ToLower(val) { | ||
case "true", "yes", "on", "1": | ||
return pyBool(true) | ||
return True | ||
case "false", "no", "off", "0": | ||
return pyBool(false) | ||
return False | ||
default: | ||
log.Fatalf("%s: invalid bool value: %v", key, val) | ||
return pyNone{} | ||
|
@@ -243,7 +252,7 @@ func toPyObject(key, val, toType string, optional bool) pyObject { | |
log.Fatalf("%s: invalid int value: %v", key, val) | ||
return pyNone{} | ||
} | ||
return pyInt(i) | ||
return newPyInt(i) | ||
default: | ||
log.Fatalf("%s: invalid plugin configuration field type: %v", key, toType) | ||
return pyNone{} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is pretty unwieldy. Are we really calling this so frequently that it's worth making the code that much more complicated?
I'd expect under most circumstances the vast majority of wall-clock time to be spent on the build steps themselves, rather than anything to do with parsing BUILD files?
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.
Or even just using string concatenation:
But this won't call into the
Stringer
interface if any of these variables aren't astring
.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.
It's called a lot more often than you'd expect. The way subrepos + plugins work with go_repo each being their own subrepo, it's called often.
Well it depends what you're doing. Things like
plz query changes
are usually blocked by parsing files.