Skip to content

Commit 2be0721

Browse files
authored
fixes vtable documentation in tut2 (#24304)
ref https://forum.nim-lang.org/t/12537#77311
1 parent f191ba8 commit 2be0721

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

doc/tut2.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,10 +347,12 @@ As the example demonstrates, invocation of a multi-method cannot be ambiguous:
347347
Collide 2 is preferred over collide 1 because the resolution works from left to
348348
right. Thus `Unit, Thing` is preferred over `Thing, Unit`.
349349

350-
**Performance note**: Nim does not produce a virtual method table, but
351-
generates dispatch trees. This avoids the expensive indirect branch for method
352-
calls and enables inlining. However, other optimizations like compile time
353-
evaluation or dead code elimination do not work with methods.
350+
**Performance note**: Nim generates dispatch trees for methods by default.
351+
With `--experimental:vtables`, it also provides an option to generate
352+
a virtual method table for methods,
353+
which tends to produce better performance in general,
354+
especially for deep object hierarchies.
355+
However, other optimizations like compile time evaluation or dead code elimination do not work with methods.
354356

355357

356358
Exceptions

0 commit comments

Comments
 (0)