Every time CalculatePositions is called (e.g. from adding/removing/expanding/collapsing items), wxGenericTreeCtrl calls GetTextExtent for every single item in the tree.
GetTextExtent is a relatively slow function, so tree operations on trees with hundreds if not thousands of items take a lot of time.
With the attached patch, the result of GetTextExtent is cached and only discarded if the item text or item attributes change.