Skip to content

Commit d016b24

Browse files
author
Benoit Hudson
committed
Drive-by improve a hashtable to hashset.
Also added comments explaining what the hashset is about.
1 parent c07fff0 commit d016b24

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/runtime/typemanager.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,10 @@ internal static IntPtr AllocateTypeObject(string name)
454454
/// </summary>
455455
internal static void InitializeSlots(IntPtr type, Type impl)
456456
{
457-
var seen = new Hashtable(8);
457+
// We work from the most-derived class up; make sure to get
458+
// the most-derived slot and not to override it with a base
459+
// class's slot.
460+
var seen = new HashSet<string>();
458461
Type offsetType = typeof(TypeOffset);
459462

460463
while (impl != null)
@@ -473,7 +476,7 @@ internal static void InitializeSlots(IntPtr type, Type impl)
473476
continue;
474477
}
475478

476-
if (seen[name] != null)
479+
if (seen.Contains(name))
477480
{
478481
continue;
479482
}
@@ -484,7 +487,7 @@ internal static void InitializeSlots(IntPtr type, Type impl)
484487
IntPtr slot = Interop.GetThunk(method);
485488
Marshal.WriteIntPtr(type, offset, slot);
486489

487-
seen[name] = 1;
490+
seen.Add(name);
488491
}
489492

490493
impl = impl.BaseType;

0 commit comments

Comments
 (0)