just for clarity :-) - like this?
```
        if (hasArray()) {
            if (length == 0) {
                return BytesRef.EMPTY_BYTES;
            }

            BytesRef ref = new BytesRef();
            bytearray.get(offset, length, ref);
            return ref.bytes;
        }
```