Go to the first, previous, next, last section, table of contents.


10. Internals

10.1 Why C++ ?

Using C++ as an implementation language provides

With these language features, there is no need for two separate languages, one for the implementation of the library and one in which the library's users can program. This means that a prototype implementation of an algorithm can be integrated into the library immediately after it has been tested and debugged. No need to rewrite it in a low-level language after having prototyped in a high-level language.

10.2 Memory efficiency

In order to save memory allocations, CLN implements:

10.3 Speed efficiency

Speed efficiency is obtained by the combination of the following tricks and algorithms:

10.4 Garbage collection

All the number classes are reference count classes: They only contain a pointer to an object in the heap. Upon construction, assignment and destruction of number objects, only the objects' reference count are manipulated.

Memory occupied by number objects are automatically reclaimed as soon as their reference count drops to zero.

For number rings, another strategy is implemented: There is a cache of, for example, the modular integer rings. A modular integer ring is destroyed only if its reference count dropped to zero and the cache is about to be resized. The effect of this strategy is that recently used rings remain cached, whereas undue memory consumption through cached rings is avoided.


Go to the first, previous, next, last section, table of contents.