Skip to content

Commit 49bb078

Browse files
committed
More renames
1 parent a0bffad commit 49bb078

1 file changed

Lines changed: 21 additions & 31 deletions

File tree

src/Compilers/Core/Portable/Emit/EditAndContinue/DeltaMetadataWriter.cs

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,8 @@ protected override IReadOnlyList<IFieldDefinition> GetFieldDefs()
319319

320320
protected override bool TryGetTypeDefinitionHandle(ITypeDefinition def, out TypeDefinitionHandle handle)
321321
{
322-
int index;
323-
bool result = _typeDefs.TryGetRowId(def, out index);
324-
handle = MetadataTokens.TypeDefinitionHandle(index);
322+
bool result = _typeDefs.TryGetRowId(def, out int rowId);
323+
handle = MetadataTokens.TypeDefinitionHandle(rowId);
325324
return result;
326325
}
327326

@@ -342,9 +341,8 @@ protected override IReadOnlyList<ITypeDefinition> GetTypeDefs()
342341

343342
protected override bool TryGetMethodDefinitionHandle(IMethodDefinition def, out MethodDefinitionHandle handle)
344343
{
345-
int index;
346-
bool result = _methodDefs.TryGetRowId(def, out index);
347-
handle = MetadataTokens.MethodDefinitionHandle(index);
344+
bool result = _methodDefs.TryGetRowId(def, out int rowId);
345+
handle = MetadataTokens.MethodDefinitionHandle(rowId);
348346
return result;
349347
}
350348

@@ -520,16 +518,13 @@ protected override void CreateIndicesForNonTypeMembers(ITypeDefinition typeDef)
520518
throw ExceptionUtilities.UnexpectedValue(change);
521519
}
522520

523-
int typeIndex;
524-
var ok = _typeDefs.TryGetRowId(typeDef, out typeIndex);
525-
Debug.Assert(ok);
521+
int typeRowId = _typeDefs.GetRowId(typeDef);
526522

527523
foreach (var eventDef in typeDef.GetEvents(this.Context))
528524
{
529-
int eventMapIndex;
530-
if (!_eventMap.TryGetRowId(typeIndex, out eventMapIndex))
525+
if (!_eventMap.Contains(typeRowId))
531526
{
532-
_eventMap.Add(typeIndex);
527+
_eventMap.Add(typeRowId);
533528
}
534529

535530
this.AddDefIfNecessary(_eventDefs, eventDef);
@@ -562,10 +557,9 @@ protected override void CreateIndicesForNonTypeMembers(ITypeDefinition typeDef)
562557

563558
foreach (var propertyDef in typeDef.GetProperties(this.Context))
564559
{
565-
int propertyMapIndex;
566-
if (!_propertyMap.TryGetRowId(typeIndex, out propertyMapIndex))
560+
if (!_propertyMap.Contains(typeRowId))
567561
{
568-
_propertyMap.Add(typeIndex);
562+
_propertyMap.Add(typeRowId);
569563
}
570564

571565
this.AddDefIfNecessary(_propertyDefs, propertyDef);
@@ -579,17 +573,14 @@ protected override void CreateIndicesForNonTypeMembers(ITypeDefinition typeDef)
579573
var methodDef = (IMethodDefinition?)methodImpl.ImplementingMethod.AsDefinition(this.Context);
580574
RoslynDebug.AssertNotNull(methodDef);
581575

582-
int methodDefIndex;
583-
ok = _methodDefs.TryGetRowId(methodDef, out methodDefIndex);
584-
Debug.Assert(ok);
576+
int methodDefRowId = _methodDefs.GetRowId(methodDef);
585577

586578
// If there are N existing MethodImpl entries for this MethodDef,
587579
// those will be index:1, ..., index:N, so it's sufficient to check for index:1.
588-
int methodImplIndex;
589-
var key = new MethodImplKey(methodDefIndex, index: 1);
590-
if (!_methodImpls.TryGetRowId(key, out methodImplIndex))
580+
var key = new MethodImplKey(methodDefRowId, index: 1);
581+
if (!_methodImpls.Contains(key))
591582
{
592-
implementingMethods.Add(methodDefIndex);
583+
implementingMethods.Add(methodDefRowId);
593584
this.methodImplList.Add(methodImpl);
594585
}
595586
}
@@ -600,9 +591,8 @@ protected override void CreateIndicesForNonTypeMembers(ITypeDefinition typeDef)
600591
int index = 1;
601592
while (true)
602593
{
603-
int methodImplIndex;
604594
var key = new MethodImplKey(methodDefIndex, index);
605-
if (!_methodImpls.TryGetRowId(key, out methodImplIndex))
595+
if (!_methodImpls.Contains(key))
606596
{
607597
_methodImpls.Add(key);
608598
break;
@@ -801,12 +791,8 @@ private void PopulateEncLogTableEventsOrProperties<T>(
801791
{
802792
if (index.IsAddedNotChanged(member))
803793
{
804-
int typeIndex = _typeDefs.GetRowId(member.ContainingTypeDefinition);
805-
Debug.Assert(typeIndex > 0);
806-
807-
int mapRowId;
808-
var ok = map.TryGetRowId(typeIndex, out mapRowId);
809-
Debug.Assert(ok);
794+
int typeRowId = _typeDefs.GetRowId(member.ContainingTypeDefinition);
795+
int mapRowId = map.GetRowId(typeRowId);
810796

811797
metadata.AddEncLogEntry(
812798
entity: MetadataTokens.Handle(mapTable, mapRowId),
@@ -1195,15 +1181,19 @@ public DefinitionIndexBase(int lastRowId, IEqualityComparer<T>? comparer = null)
11951181

11961182
public int GetRowId(T item)
11971183
{
1198-
TryGetRowId(item, out int rowId);
1184+
bool containsItem = TryGetRowId(item, out int rowId);
11991185

12001186
// Fails if we are attempting to make a change that should have been reported as rude,
12011187
// e.g. the corresponding definitions type don't match, etc.
1188+
Debug.Assert(containsItem);
12021189
Debug.Assert(rowId > 0);
12031190

12041191
return rowId;
12051192
}
12061193

1194+
public bool Contains(T item)
1195+
=> TryGetRowId(item, out _);
1196+
12071197
// A method rather than a property since it freezes the table.
12081198
public IReadOnlyDictionary<T, int> GetAdded()
12091199
{

0 commit comments

Comments
 (0)