diff options
author | 2023-01-03 15:03:23 +0000 | |
---|---|---|
committer | 2023-01-04 13:18:41 +0000 | |
commit | 1fcd71f039dc9b6e396a5151db131be05ac5b290 (patch) | |
tree | b03e3eca6fca853e74428ca1fe61b8744cd1843c /runtime/string_builder_append.cc | |
parent | 1a214cea72b9ea4a3125f0e920dbcc904dbd6dfa (diff) |
Use named constant for max FP string length.
Address late comments on
https://android-review.googlesource.com/968339 .
Test: m
Bug: 19575890
Change-Id: I111f5aaa9119af6d44f186ba111f7917cd7bac9a
Diffstat (limited to 'runtime/string_builder_append.cc')
-rw-r--r-- | runtime/string_builder_append.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/runtime/string_builder_append.cc b/runtime/string_builder_append.cc index ef6969d4d0..0083b912a5 100644 --- a/runtime/string_builder_append.cc +++ b/runtime/string_builder_append.cc @@ -105,7 +105,10 @@ class StringBuilderAppend::Builder { // We convert float/double values using jdk.internal.math.FloatingDecimal which uses // a thread-local converter under the hood. As we may have more than one // float/double argument, we need to copy the data out of the converter. - uint8_t converted_fp_args_[kMaxArgs][26]; // 26 is the maximum number of characters. + // Maximum number of characters is 26. See BinaryToASCIIBuffer.buffer in FloatingDecimal.java . + // (This is more than enough for the `ExceptionalBinaryToASCIIBuffer` cases.) + static constexpr size_t kBinaryToASCIIBufferSize = 26; + uint8_t converted_fp_args_[kMaxArgs][kBinaryToASCIIBufferSize]; int32_t converted_fp_arg_lengths_[kMaxArgs]; // The length and flag to store when the AppendBuilder is used as a pre-fence visitor. @@ -164,7 +167,7 @@ inline CharType* StringBuilderAppend::Builder::AppendFpArg(ObjPtr<mirror::String DCHECK_LE(fp_arg_index, std::size(converted_fp_args_)); const uint8_t* src = converted_fp_args_[fp_arg_index]; size_t length = converted_fp_arg_lengths_[fp_arg_index]; - DCHECK_LE(length, std::size(converted_fp_args_[0])); + DCHECK_LE(length, kBinaryToASCIIBufferSize); DCHECK_LE(length, RemainingSpace(new_string, data)); return std::copy_n(src, length, data); } |