Created
May 21, 2020 19:53
-
-
Save enebo/8fa2c17a3384a962da7b24b0168c40d2 to your computer and use it in GitHub Desktop.
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
diff --git a/core/src/main/java/org/jruby/util/ConvertBytes.java b/core/src/main/java/org/jruby/util/ConvertBytes.java | |
index 644d46da13..a2d4a8709d 100644 | |
--- a/core/src/main/java/org/jruby/util/ConvertBytes.java | |
+++ b/core/src/main/java/org/jruby/util/ConvertBytes.java | |
@@ -176,10 +176,13 @@ public class ConvertBytes { | |
if (neg) newSize++; | |
string.resize(newSize); | |
ByteList byteList = string.getByteList(); | |
+ byte[] bytes = byteList.getUnsafeBytes(); | |
+ int beg = byteList.begin(); | |
- do { | |
- byteList.set(--newSize, LOWER_DIGITS[(int) (i % 10)]); | |
- } while ((i /= 10) > 0); | |
+ for (int n = newSize - 1; i > 0 && n >= newSize - len; n--) { | |
+ bytes[beg + n] = LOWER_DIGITS[(int) (i % 10)]; | |
+ i /= 10; | |
+ } | |
if (neg) byteList.set(--newSize, '-'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment