-
Notifications
You must be signed in to change notification settings - Fork 18.1k
cmd/compile: inline harder to optimize closure allocation #16759
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
Comments
Note that this is about all the It looks like if the compiler could inline the super-trivial single-line makeCutsetFunc, then the escape analysis does work. This patch makes removes the only allocation from diff --git a/src/strings/strings.go b/src/strings/strings.go
index 738c493..7faa447 100644
--- a/src/strings/strings.go
+++ b/src/strings/strings.go
@@ -600,7 +600,7 @@ func TrimLeft(s string, cutset string) string {
if s == "" || cutset == "" {
return s
}
- return TrimLeftFunc(s, makeCutsetFunc(cutset))
+ return TrimLeftFunc(s, func(r rune) bool { return IndexRune(cutset, r) >= 0 })
}
where func makeCutsetFunc(cutset string) func(rune) bool {
return func(r rune) bool { return IndexRune(cutset, r) >= 0 }
} I guess that is too "hairy" to be inlined, but it probably should be. |
I started on inlining closures during the last freeze and got stuck. I'll mail some of the finished preliminary work; it's just waiting for me to get to it. Lots to mail, little time. |
True. this is exactly dup. |
Uh oh!
There was an error while loading. Please reload this page.
I'm not sure but sometimes using closure causes unwanted allocations.
Please see https://go-review.googlesource.com/#/c/27211/ and https://go-review.googlesource.com/#/c/27210/.
I also don't know this is fixable or not, sorry.
The text was updated successfully, but these errors were encountered: