diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bfa211c9..50e8ccc2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,9 @@ and what APIs have changed, if applicable. ## [Unreleased] +## [29.62.1] - 2024-11-05 +- Enhancements in ByteString and its ByteIterator to reduce object allocation + ## [29.62.0] - 2024-10-28 - Check and take configurable action for invalid partition weight @@ -5755,7 +5758,8 @@ patch operations can re-use these classes for generating patch messages. ## [0.14.1] -[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.62.0...master +[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.62.1...master +[29.62.1]: https://github.com/linkedin/rest.li/compare/v29.62.0...v29.62.1 [29.62.0]: https://github.com/linkedin/rest.li/compare/v29.61.0...v29.62.0 [29.61.0]: https://github.com/linkedin/rest.li/compare/v29.60.0...v29.61.0 [29.60.0]: https://github.com/linkedin/rest.li/compare/v29.59.0...v29.60.0 diff --git a/data/src/main/java/com/linkedin/data/ByteString.java b/data/src/main/java/com/linkedin/data/ByteString.java index c28765308..49307eb41 100644 --- a/data/src/main/java/com/linkedin/data/ByteString.java +++ b/data/src/main/java/com/linkedin/data/ByteString.java @@ -669,6 +669,12 @@ private ByteIterator copy() return new ByteIterator(this); } + private void fillFromAnother(ByteIterator other) { + _currentByteArray = other._currentByteArray; + _currentByteIndex = other._currentByteIndex; + _finished = other._finished; + } + private void next() { //Shift the internal pointer to the next byte. @@ -737,9 +743,6 @@ public int indexOfBytes(byte[] targetBytes) //This is a reference on where to resume in case we get a mismatch. ByteIterator resumeByteIterator = byteIterator.copy(); - //We skip the first since byteIterator will begin there. - resumeByteIterator.next(); - for (int i = 0; i < targetBytes.length;) { //If we have exhausted everything in the ByteString, then we return -1. @@ -754,11 +757,8 @@ public int indexOfBytes(byte[] targetBytes) //There was a mismatch so we reset i and prepare to start over. i = 0; //Update byteIterator to point to the next byte where our comparison will begin. - byteIterator = resumeByteIterator; - //Keep track of where to resume in the future. - resumeByteIterator = resumeByteIterator.copy(); - //Skip the next since byteIterator will begin there. resumeByteIterator.next(); + byteIterator.fillFromAnother(resumeByteIterator); continue; } diff --git a/gradle.properties b/gradle.properties index be86bdb5d..4372902d7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -version=29.62.0 +version=29.62.1 group=com.linkedin.pegasus org.gradle.configureondemand=true org.gradle.parallel=true