Fix the logic of joining byte arrays when there is no items#925
Merged
Conversation
Codecov Report
@@ Coverage Diff @@
## release/1.13.0 #925 +/- ##
==================================================
- Coverage 83.05% 83.04% -0.02%
==================================================
Files 267 267
Lines 9057 9060 +3
Branches 1456 1457 +1
==================================================
+ Hits 7522 7523 +1
- Misses 1138 1141 +3
+ Partials 397 396 -1
|
xgouchet
suggested changes
May 5, 2022
Comment on lines
+44
to
+46
| this.sumOf { it.size } + | ||
| prefix.size + suffix.size + separator.size * (this.size - 1) | ||
| prefix.size + suffix.size + | ||
| if (this.isNotEmpty()) separator.size * (this.size - 1) else 0 |
Contributor
There was a problem hiding this comment.
This begins to be hard to read, it'd be nice to split that into variables, e.g.:
val dataSize = this.sumOf { it.size }
val separatorsSize = if (this.isNotEmpty()) separator.size * (this.size - 1) else 0
val size = dataSize + separatorsSize + prefix.size + suffix.size
val result = ByteArray(size)
0xnm
force-pushed
the
nogorodnikov/fix-array-join-logic
branch
from
May 5, 2022 07:30
4f2f927 to
c35c5a1
Compare
xgouchet
approved these changes
May 5, 2022
mariusc83
approved these changes
May 5, 2022
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.
What does this PR do?
Fixes a silly bug: size taken by separators could be negative in case of empty collection (doesn't impact any data upload though).
Review checklist (to be filled by reviewers)