| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 14)

Effect of Subclassing, Stability, and Casting on List and Array Value Assignments

This test compares the efficiency of assignment statements where you assign an element of a user-defined subclass of array is assigned to a specific type, with and without stability declarations. This test also compares the effects of casting on an array subclass. Specifically, the tests are:

Changing a native array element is almost six times faster than changing a subclassed array element. If you add stability, the performance improves somewhat; however, if you use casting, you can change a subclassed array element in the same amount of time it takes to change a native array element.

For lists, inserting into a subclassed list is less efficient than inserting into a native list, and stability declarations only improve this performance slightly. Casting has no effect on lists.

Thus, whenever possible, you should use a native array, or if you are subclassing, declare local variables, using casting.

| Prev | Next | Start of Chapter | End of Chapter | Contents | Glossary | Index | Comments | (5 out of 14)

Copyright © 1997 Gensym Corporation, Inc.