Support expressions in selectattr/rejectattr again, more efficiently v2#454
Open
Support expressions in selectattr/rejectattr again, more efficiently v2#454
Conversation
…ore efficiently""
samukce
reviewed
Jun 16, 2020
| interpreter.getContext().removeResolvedExpression(expression); | ||
|
|
||
| return result; | ||
| } |
Contributor
There was a problem hiding this comment.
There is an unused method parameter in this method. Should we remove it? Map<String, Object> kwargs
samukce
reviewed
Jun 16, 2020
| } | ||
|
|
||
| private String generateTempVariable(String tempValue, String expression) { | ||
| return String.format("%s.%s", tempValue, expression).trim(); |
Contributor
There was a problem hiding this comment.
The String.format has some performance issues. So, for curiosity, I ran a benchmark to compare the approaches.
Those are the results:
Benchmark Mode Cnt Score Error Units
StringConcatSimulation.concatWithConcatFunction ss 25 1.900 ± 0.120 ms/op
StringConcatSimulation.concatWithPlus ss 25 2.079 ± 0.438 ms/op
StringConcatSimulation.concatWithStringBuilder ss 25 1.871 ± 0.436 ms/op
StringConcatSimulation.concatWithStringBuilderWithCount ss 25 1.720 ± 0.255 ms/op
StringConcatSimulation.concatWithStringFormat ss 25 15.145 ± 2.836 ms/opI would suggest using StringBuilder instead.
Suggested change
| return String.format("%s.%s", tempValue, expression).trim(); | |
| return new StringBuilder() | |
| .append(tempValue) | |
| .append(".") | |
| .append(expression) | |
| .toString() | |
| .trim(); |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Take 2. I will fix this up.