A new optimization about method_exchangeImplementations in objc4–818.2

visitor
Jan 11, 2021

Before objc4–818.2, the runtime system will flush the method cache list of all objc class when using method_exchangeImplementations. Because the API of method_exchangeImplementations only requires two “Methods” as parameters, and the runtime system does not know the “Method” belongs to which class, it has to flush all the caches to keep the method dispatch system running well.

However, there is a new optimization in objc4–818.2. The runtime system will judge whether the replacing method is in the method cache list of a certain class. It does not flush the cache if not.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

No responses yet

Write a response