[Java][FlexBuffers] Make FlexBuffersBuilder reusable by adding clear() (#5889) (#5890)

This commit is contained in:
Markus Junginger
2020-05-07 21:26:55 +02:00
committed by GitHub
parent e84cbff673
commit c2da8d5d85
5 changed files with 38 additions and 0 deletions

View File

@@ -151,6 +151,17 @@ public class FlexBuffersBuilder {
this(bb, BUILDER_FLAG_SHARE_KEYS);
}
/**
* Reset the FlexBuffersBuilder by purging all data that it holds.
*/
public void clear(){
bb.clear();
stack.clear();
keyPool.clear();
stringPool.clear();
finished = false;
}
/**
* Return `ByteBuffer` containing FlexBuffer message. {@code #finish()} must be called before calling this
* function otherwise an assert will trigger.