some optimizations to giniallocation