Skip to content

Commit 09ea714

Browse files
committed
replace boxing Stack with generic Stack<bool> in BamlReader
1 parent 3f568fe commit 09ea714

File tree

1 file changed

+15
-15
lines changed
  • src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup

1 file changed

+15
-15
lines changed

src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Markup/BamlReader.cs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1447,9 +1447,9 @@ private BamlKeyInfo ProcessKeyTree()
14471447
// track of when we have entered a constructor parameter section and when
14481448
// we have written out the first parameter to handle adding commas between
14491449
// constructor parameters.
1450-
Stack readProperty = new Stack();
1451-
Stack readConstructor = new Stack();
1452-
Stack readFirstConstructor = new Stack();
1450+
Stack<bool> readProperty = new();
1451+
Stack<bool> readConstructor = new();
1452+
Stack<bool> readFirstConstructor = new();
14531453
readProperty.Push(false); // Property has not yet been read
14541454
readConstructor.Push(false); // Constructor section has not been read
14551455
readFirstConstructor.Push(false); // First constructor parameter has not been read
@@ -1494,7 +1494,7 @@ private BamlKeyInfo ProcessKeyTree()
14941494
case BamlRecordType.PropertyComplexStart:
14951495
ReadPropertyComplexStartRecord();
14961496
nodeInfo = (BamlNodeInfo)_nodeStack.Pop();
1497-
if ((bool)readProperty.Pop())
1497+
if (readProperty.Pop())
14981498
{
14991499
markupString += ", ";
15001500
}
@@ -1520,12 +1520,12 @@ private BamlKeyInfo ProcessKeyTree()
15201520
// If the text contains '{' or '}' then we have to escape these
15211521
// so that it won't be interpreted as a MarkupExtension
15221522
string escapedString = EscapeString(((BamlTextRecord)_currentBamlRecord).Value);
1523-
if ((bool)readFirstConstructor.Peek())
1523+
if (readFirstConstructor.Peek())
15241524
{
15251525
markupString += ", ";
15261526
}
15271527
markupString += escapedString;
1528-
if ((bool)readConstructor.Peek())
1528+
if (readConstructor.Peek())
15291529
{
15301530
readFirstConstructor.Pop();
15311531
readFirstConstructor.Push(true);
@@ -1534,11 +1534,11 @@ private BamlKeyInfo ProcessKeyTree()
15341534

15351535
case BamlRecordType.ElementStart:
15361536
// Process commas between constructor parameters
1537-
if ((bool)readFirstConstructor.Peek())
1537+
if (readFirstConstructor.Peek())
15381538
{
15391539
markupString += ", ";
15401540
}
1541-
if ((bool)readConstructor.Peek())
1541+
if (readConstructor.Peek())
15421542
{
15431543
readFirstConstructor.Pop();
15441544
readFirstConstructor.Push(true);
@@ -1585,11 +1585,11 @@ private BamlKeyInfo ProcessKeyTree()
15851585

15861586
case BamlRecordType.ConstructorParameterType:
15871587
// Process commas between constructor parameters
1588-
if ((bool)readFirstConstructor.Peek())
1588+
if (readFirstConstructor.Peek())
15891589
{
15901590
markupString += ", ";
15911591
}
1592-
if ((bool)readConstructor.Peek())
1592+
if (readConstructor.Peek())
15931593
{
15941594
readFirstConstructor.Pop();
15951595
readFirstConstructor.Push(true);
@@ -1603,7 +1603,7 @@ private BamlKeyInfo ProcessKeyTree()
16031603
{
16041604
string value = ((BamlPropertyRecord)_currentBamlRecord).Value;
16051605
BamlPropertyInfo propertyInfo = ReadPropertyRecordCore(value);
1606-
if ((bool)readProperty.Pop())
1606+
if (readProperty.Pop())
16071607
{
16081608
markupString += ", ";
16091609
}
@@ -1615,7 +1615,7 @@ private BamlKeyInfo ProcessKeyTree()
16151615
case BamlRecordType.PropertyCustom:
16161616
{
16171617
BamlPropertyInfo propertyInfo = GetPropertyCustomRecordInfo();
1618-
if ((bool)readProperty.Pop())
1618+
if (readProperty.Pop())
16191619
{
16201620
markupString += ", ";
16211621
}
@@ -1628,7 +1628,7 @@ private BamlKeyInfo ProcessKeyTree()
16281628
{
16291629
string value = MapTable.GetStringFromStringId(((BamlPropertyStringReferenceRecord)_currentBamlRecord).StringId);
16301630
BamlPropertyInfo propertyInfo = ReadPropertyRecordCore(value);
1631-
if ((bool)readProperty.Pop())
1631+
if (readProperty.Pop())
16321632
{
16331633
markupString += ", ";
16341634
}
@@ -1642,7 +1642,7 @@ private BamlKeyInfo ProcessKeyTree()
16421642
string value = GetTypeValueString(((BamlPropertyTypeReferenceRecord)_currentBamlRecord).TypeId);
16431643
string attributeName = MapTable.GetAttributeNameFromId(
16441644
((BamlPropertyTypeReferenceRecord)_currentBamlRecord).AttributeId);
1645-
if ((bool)readProperty.Pop())
1645+
if (readProperty.Pop())
16461646
{
16471647
markupString += ", ";
16481648
}
@@ -1656,7 +1656,7 @@ private BamlKeyInfo ProcessKeyTree()
16561656
string value = GetExtensionValueString((BamlPropertyWithExtensionRecord)_currentBamlRecord);
16571657
string attributeName = MapTable.GetAttributeNameFromId(
16581658
((BamlPropertyWithExtensionRecord)_currentBamlRecord).AttributeId);
1659-
if ((bool)readProperty.Pop())
1659+
if (readProperty.Pop())
16601660
{
16611661
markupString += ", ";
16621662
}

0 commit comments

Comments
 (0)