From aac33a7a43ded44481f4791a7c368ed72fce5f61 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 11 Oct 2022 11:39:40 -0400 Subject: [PATCH] mention marker traits --- text/0000-dyn-upcasting.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/text/0000-dyn-upcasting.md b/text/0000-dyn-upcasting.md index bf7cb90c..51dfaab7 100644 --- a/text/0000-dyn-upcasting.md +++ b/text/0000-dyn-upcasting.md @@ -186,7 +186,11 @@ Given `trait A(n+1): Bn + Cn {}, trait Bn: An { fn bn(&self); }, trait Cn: An { ## Why not adopt a "pointer-based" vtable layout? -In this stable, every trait would have their own vtable, and we would embed links to each of them in the subtrait's vtable. This was rejected as it would be less efficient for the single-inheritance case, which is common. +The current implementation uses a hybrid strategy that *sometimes* uses pointers. This was deemed preferable to using a *purely* pointer-based layout because it would be less efficient for the single-inheritance case, which is common. + +## Are there other optimizations possible with vtable layout? + +Certainly. Given that the RFC doesn't specify vtable layout, we still have room to do experimentation. For example, we might do special optimizations for traits with no methods. # Prior art [prior-art]: #prior-art