libui: rewrite Region with FatVector
Region is heavily used by SurfaceFlinger and the Android animation framework, but it uses the libutils Vector internally. libutils Vector allocates four elements via malloc() regardless of the contents of the Vector. However, Region is overwhelmingly a single-element Vector (occasionally two), which can be allocated on the stack easily enough. FatVector is an existing wrapper around std::vector that allows for a stack-allocated vector when the contents are small enough. Using FatVector in Region instead of libutils Vector avoids all of the malloc/free overhead, which improves SurfaceFlinger per-frame runtime by ~4%. This CL moves FatVector from libhwui to make it usable by Region. Test: boots, works, passes tests Bug: 149096186 Change-Id: I265c6c831bc82f31afe0d100aec2f98344f2390b
Loading
Please register or sign in to comment