You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Optimize TypeSafeMatching iteration over class methods (#2729)
`Class.getMethods` is an inefficient method call which is being called on
each mock invocation. It ends up constructing new `Method` objects for
each method on the class, and this can dominate the overall performance
of Mockito mocks. This commit caches the result of the computation.
Once concern is that this change uses some static state. I considered:
- Instance state - based on where this type is constructed it seemed
like it'd be a big imposition on code readability elsewhere.
- Weakly referenced map. Mockito has a type for this, but the
constructor of that type produces a Thread with which to clean up.
Both of these seemed like overkill compared to the overhead expected
in the real world (which should be on the order of a few kilobytes of
RAM at most).
Fixes#2723
0 commit comments