aboutsummaryrefslogtreecommitdiff
path: root/java/core/src/main/java/com/google/protobuf/Utf8.java
diff options
context:
space:
mode:
authorFeng Xiao <xfxyjwf@gmail.com>2018-05-14 13:41:03 -0700
committerGitHub <noreply@github.com>2018-05-14 13:41:03 -0700
commit6dda83dc8c0c819d6a51ccc18bf9c609d25e62e0 (patch)
treeccce3a022c1c8b460180341c69143ce1eba01c9c /java/core/src/main/java/com/google/protobuf/Utf8.java
parente7eeb7004bbda01f62ea5e66f156645c3dadf1e2 (diff)
parent92ac1ed6a5baf58651e70759021910baa614332a (diff)
downloadprotobuf-6dda83dc8c0c819d6a51ccc18bf9c609d25e62e0.tar.gz
protobuf-6dda83dc8c0c819d6a51ccc18bf9c609d25e62e0.tar.bz2
protobuf-6dda83dc8c0c819d6a51ccc18bf9c609d25e62e0.zip
Merge pull request #4611 from anuraaga/remove-string-move
[Java] Remove unsafe no-copy String allocation since it's not useful in receā€¦
Diffstat (limited to 'java/core/src/main/java/com/google/protobuf/Utf8.java')
-rw-r--r--java/core/src/main/java/com/google/protobuf/Utf8.java10
1 files changed, 2 insertions, 8 deletions
diff --git a/java/core/src/main/java/com/google/protobuf/Utf8.java b/java/core/src/main/java/com/google/protobuf/Utf8.java
index 6968abb3..de75fe6b 100644
--- a/java/core/src/main/java/com/google/protobuf/Utf8.java
+++ b/java/core/src/main/java/com/google/protobuf/Utf8.java
@@ -1474,10 +1474,7 @@ final class Utf8 {
}
}
- if (resultPos < resultArr.length) {
- resultArr = Arrays.copyOf(resultArr, resultPos);
- }
- return UnsafeUtil.moveToString(resultArr);
+ return new String(resultArr, 0, resultPos);
}
@Override
@@ -1553,10 +1550,7 @@ final class Utf8 {
}
}
- if (resultPos < resultArr.length) {
- resultArr = Arrays.copyOf(resultArr, resultPos);
- }
- return UnsafeUtil.moveToString(resultArr);
+ return new String(resultArr, 0, resultPos);
}
@Override