Skip to content

Commit e364afb

Browse files
dannyd89Daniel Draghicieiriktsarpalis
authored
Removed unused field in JsonProperty (#113643) (#114071)
Removed the unused field _name in JsonProperty which was never initialized anyway. Co-authored-by: Daniel Draghici <[email protected]> Co-authored-by: Eirik Tsarpalis <[email protected]>
1 parent 5b5de26 commit e364afb

File tree

1 file changed

+3
-11
lines changed
  • src/libraries/System.Text.Json/src/System/Text/Json/Document

1 file changed

+3
-11
lines changed

src/libraries/System.Text.Json/src/System/Text/Json/Document/JsonProperty.cs

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public readonly struct JsonProperty
1616
/// The value of this property.
1717
/// </summary>
1818
public JsonElement Value { get; }
19-
private string? _name { get; }
2019

2120
internal JsonProperty(JsonElement value)
2221
{
@@ -25,8 +24,9 @@ internal JsonProperty(JsonElement value)
2524

2625
/// <summary>
2726
/// The name of this property.
27+
/// This allocates a new string instance for each call.
2828
/// </summary>
29-
public string Name => _name ?? Value.GetPropertyName();
29+
public string Name => Value.GetPropertyName();
3030

3131
/// <summary>
3232
/// Compares <paramref name="text" /> to the name of this property.
@@ -116,15 +116,7 @@ public void WriteTo(Utf8JsonWriter writer)
116116
{
117117
ArgumentNullException.ThrowIfNull(writer);
118118

119-
if (_name is null)
120-
{
121-
Value.WritePropertyNameTo(writer);
122-
}
123-
else
124-
{
125-
writer.WritePropertyName(_name);
126-
}
127-
119+
Value.WritePropertyNameTo(writer);
128120
Value.WriteTo(writer);
129121
}
130122

0 commit comments

Comments
 (0)