O'Reilly logo

Game Programming Gems 8 by Adam Lake

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 4.1. Fast-IsA

Joshua Grass, PhD

Many advanced scripting languages have notions of class hierarchies similar to those in programming languages such as C++, C#, or Java. Scripts written in these languages often need to perform safe casts or IsA checks on objects. In our game, This Is Vegas, we found that the amount of time spent performing the IsA check was not insignificant. This gem describes a method for processing class hierarchy data to change the IsA operation from O(N) to O(1). In our case, this resulted in a performance improvement of more than one percent for the cost of adding one DWORD for each class (depending on your platform; if the platform does not have the BitScanReverse operator, you will need to store ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required