-
Notifications
You must be signed in to change notification settings - Fork 56
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
Optimize std.findSubstr and std.flattenArrays #216
Optimize std.findSubstr and std.flattenArrays #216
Conversation
Do you want to merge this? |
This reverts commit eb10497.
Hmm, it looks like we're getting a compilation error in the scalajs 2.12 code because we're missing
I've gone ahead and backed out the I still think we should merge that optimization because it's a cheap win and actually was a hotspot (relatively speaking) in some files I profiled. |
I believe you can use the ++= operator in-lieu of addAll |
This reverts commit fa304b0.
Ah, good call: it looks like that's a synonym for an I've gone ahead and incorporated this suggestion, adding |
This PR implements small performance optimizations for two built-in functions:
findSubstr
is often used to implement "string contains" checks.ArrayBuilder
instead ofArrayBuffer
: in this context we only need to append and don't need to update, remove, or inspect the elements that we've written, and for those requirements ArrayBuilder is cheaper to instantiate and cheaper to invoke.Val.Num
into the array builder rather than storing indices then mapping the result into an output array: this saves an array allocation and iteration.