removed unneeded memory allocations inside onMeasure