From 7d3af290d28db91deeca7339d04aea201728c358 Mon Sep 17 00:00:00 2001 From: Matthew Nelson Date: Sat, 4 Jan 2025 07:24:27 -0500 Subject: [PATCH] Rename commonUpdate local variables --- .../core/digest/internal/-Buffer.kt | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/library/digest/src/commonMain/kotlin/org/kotlincrypto/core/digest/internal/-Buffer.kt b/library/digest/src/commonMain/kotlin/org/kotlincrypto/core/digest/internal/-Buffer.kt index 65654a9..8ec22ae 100644 --- a/library/digest/src/commonMain/kotlin/org/kotlincrypto/core/digest/internal/-Buffer.kt +++ b/library/digest/src/commonMain/kotlin/org/kotlincrypto/core/digest/internal/-Buffer.kt @@ -70,43 +70,43 @@ internal inline fun Buffer.commonUpdate( ) { val buf = value val blockSize = buf.size - var offsInput = offset - val limit = offsInput + len - var offsBuf = bufPos + val limitInput = offset + len + var posInput = offset + var posBuf = bufPos - if (offsBuf > 0) { + if (posBuf > 0) { // Need to use buffered data (if possible) - if (offsBuf + len < blockSize) { + if (posBuf + len < blockSize) { // Not enough for a compression. Add it to the buffer. - input.copyInto(buf, offsBuf, offsInput, limit) - bufPosSet(offsBuf + len) + input.copyInto(buf, posBuf, posInput, limitInput) + bufPosSet(posBuf + len) return } // Add enough input to do a compression - val needed = blockSize - offsBuf - input.copyInto(buf, offsBuf, offsInput, offsInput + needed) + val needed = blockSize - posBuf + input.copyInto(buf, posBuf, posInput, posInput + needed) compressProtected(buf, 0) - offsBuf = 0 - offsInput += needed + posBuf = 0 + posInput += needed } // Chunk blocks (if possible) - while (offsInput < limit) { - val offsNext = offsInput + blockSize + while (posInput < limitInput) { + val posNext = posInput + blockSize - if (offsNext > limit) { + if (posNext > limitInput) { // Not enough for a compression. Add it to the buffer. - input.copyInto(buf, 0, offsInput, limit) - offsBuf = limit - offsInput + input.copyInto(buf, 0, posInput, limitInput) + posBuf = limitInput - posInput break } - compressProtected(input, offsInput) - offsInput = offsNext + compressProtected(input, posInput) + posInput = posNext } // Update globals - bufPosSet(offsBuf) + bufPosSet(posBuf) }