libgdx/ashley

Small enhancement for family calss

ArtCraft opened this issue · 2 comments

private static String getBitsString (Bits bits) {
        StringBuilder stringBuilder = new StringBuilder();

        int numBits = bits.length();
        for (int i = 0; i < numBits; ++i) {
            stringBuilder.append(bits.get(i) ? "1" : "0");
        }

        return stringBuilder.toString();
}

can be replaced with

private static String getBitsString (Bits bits) {
        return  Integer.toBinaryString(bits.hashCode());
}

It can't. hashCode() may return the same value for different Bits instances. This change would result in family instances getting randomly mixed up with each other.

you are right

On Mon, Jun 8, 2015 at 7:47 PM, Anton notifications@github.com wrote:

It can't. hashCode() must not return different integers for different Bits
instances. This change would result in family instances getting randomly
mixed up with each other.


Reply to this email directly or view it on GitHub
#174 (comment).