Introduction to OOP: Chapter 21 : Implementation [next] [previous] [audio] [real] [text]

Method Cache

In order to avoid the cost of a dynamic search of dispatch tables, a single global cache can be used to hold frequently invoked methods.

The cache is used as a large hash table.

Prior to searching a dispatch table, the a single hashed entry is examined - if it matches the selector being sought, the method is used, if not the dispatch table is searched and the new entry replaces the value in the hash table.

Assuming a good hash function is used, efficiency can be very high.

Intro OOP, Chapter 21, Slide 12