

Here’s the hottest part of the encoding loop for a byte (JDK10 on Ubuntu), annotated to explain what is going on.

How does it work? The best way to find out is always JMH perfasm. Since JDK8 there has been which benchmarks favourably against older library implementations.

Int i = 0 int j = 0 // 3 bytes in, 4 bytes out for ( j + 3 > 18 ) & 0x3F ] out = ENCODING out = ENCODING out = ENCODING }
