mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-02 23:08:19 +00:00
Can now use `CharSequence of String`. Works with
1. [AsciiString] (http://netty.io/4.1/api/io/netty/util/AsciiString.html) 2. [CharBuffer] (https://docs.oracle.com/javase/8/docs/api/java/nio/CharBuffer.html) 3. [StringBuilder] (https://docs.oracle.com/javase/8/docs/api/java/lang/StringBuilder.html)
This commit is contained in:
2
java/com/google/flatbuffers/FlatBufferBuilder.java
Executable file → Normal file
2
java/com/google/flatbuffers/FlatBufferBuilder.java
Executable file → Normal file
@@ -373,7 +373,7 @@ public class FlatBufferBuilder {
|
|||||||
* @param s The string to encode.
|
* @param s The string to encode.
|
||||||
* @return The offset in the buffer where the encoded string starts.
|
* @return The offset in the buffer where the encoded string starts.
|
||||||
*/
|
*/
|
||||||
public int createString(String s) {
|
public int createString(CharSequence s) {
|
||||||
int length = s.length();
|
int length = s.length();
|
||||||
int estimatedDstCapacity = (int) (length * encoder.maxBytesPerChar());
|
int estimatedDstCapacity = (int) (length * encoder.maxBytesPerChar());
|
||||||
if (dst == null || dst.capacity() < estimatedDstCapacity) {
|
if (dst == null || dst.capacity() < estimatedDstCapacity) {
|
||||||
|
|||||||
Reference in New Issue
Block a user