8247619: Improve Direct Buffering of Characters

Reviewed-by: alanb, ahgross, rhalade, psandoz
This commit is contained in:
Brian Burkhalter 2020-07-29 09:52:13 -07:00 committed by Henry Jen
parent 0408b23bcf
commit a5367cbb7a
3 changed files with 27 additions and 12 deletions

View file

@ -292,7 +292,9 @@ class Heap$Type$Buffer$RW$
public $Type$Buffer compact() {
#if[rw]
int pos = position();
int rem = limit() - pos;
int lim = limit();
assert (pos <= lim);
int rem = (pos <= lim ? lim - pos : 0);
System.arraycopy(hb, ix(pos), hb, ix(0), rem);
position(rem);
limit(capacity());