Issue #1015: Enable an detekt rule for wrap blocks in { } #1040
Issue #1015: Enable an detekt rule for wrap blocks in { } #1040
Conversation
It gets rid of new ArrayList allocation inside each call in call chain
Codecov Report
@@ Coverage Diff @@
## master #1040 +/- ##
============================================
+ Coverage 79.67% 79.72% +0.04%
+ Complexity 1491 1488 -3
============================================
Files 194 194
Lines 5807 5805 -2
Branches 936 934 -2
============================================
+ Hits 4627 4628 +1
+ Misses 742 740 -2
+ Partials 438 437 -1
Continue to review full report at Codecov.
|
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.
Thank you. This looks great. I wonder where the asSequence()
changes are coming from?
@@ -312,6 +310,7 @@ internal class DisplayToolbar( | |||
// +-------------+------------------------------------------------+ | |||
|
|||
val navigationActionsWidth = navigationActions | |||
.asSequence() |
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.
Those two asSequence()
changes seem unrelated?
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've noticed it because of IDEA inspection.
If we apply call chain on List
, on each call new ArrayList
will be created. So in worst case O((number of calls in chain) * (size of initial list))
aux memory will be allocated. asSequence
fixes it and creates only (more on less) a new Sequence
on each call.
It should improve both memory consumption and performance.
In case it seems unrelated, I can extract it to another pull request.
If you'd like me to do this, should I also extract fixes in documentation? As It seems equally unrelated to the original issue...
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.
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.
@pocmo, @Amejia481 any updates on this?
Closes #1015