jOOQ / jOOU

jOOU - Unsigned Integers jOOU provides unsigned integer versions for the four Java integer types byte, short, int and long.
http://www.jooq.org/products
Apache License 2.0
228 stars 32 forks source link

Improved hashCode() and toString() implementation #18

Closed lukaseder closed 5 years ago

lukaseder commented 5 years ago

The current implementation on e.g. UByte.toString() is:

    @Override
    public String toString() {
        return Short.valueOf(value).toString();
    }

This produces an unnecessary allocation of a java.lang.Short, when instead, we could write

    @Override
    public String toString() {
        return Short.toString(value);
    }

Other types are also affected.

Credits to @knutwannheden for discovering this.

knutwannheden commented 5 years ago

In the scope of this issue I will also fix the hashCode() methods which can be optimized in the exact same way.

lukaseder commented 5 years ago

Agreed

knutwannheden commented 5 years ago

Unfortunately only since Java 1.8, so not in jOOU-java-6.