Skip to content

Commit 5ebeb88

Browse files
committed
Make the underlying type and value readonly
1 parent b772290 commit 5ebeb88

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

ValveKeyValue/ValveKeyValue/KVDocument.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,10 @@ public class KVDocument : KVObject
2222
/// <param name="name">Root key name of the document.</param>
2323
/// <param name="root">Root value of the document.</param>
2424
public KVDocument(KVHeader header, string name, KVObject root)
25+
: base(root.ValueType, root._scalar, root._ref, root.Flag)
2526
{
2627
Header = header;
2728
Name = name;
28-
29-
// Copy the root's fields into this document object
30-
ValueType = root.ValueType;
31-
Flag = root.Flag;
32-
_scalar = root._scalar;
33-
_ref = root._ref;
3429
}
3530
}
3631
}

ValveKeyValue/ValveKeyValue/KVObject.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public partial class KVObject : IEnumerable<KeyValuePair<string, KVObject>>
1818
/// <summary>
1919
/// Gets the value type of this object.
2020
/// </summary>
21-
public KVValueType ValueType { get; internal set; }
21+
public KVValueType ValueType { get; }
2222

2323
/// <summary>
2424
/// Gets or sets the flags of this object.
@@ -27,10 +27,10 @@ public partial class KVObject : IEnumerable<KeyValuePair<string, KVObject>>
2727

2828
// Inline storage for scalar types (no boxing).
2929
// Interpretation depends on ValueType.
30-
internal long _scalar;
30+
internal readonly long _scalar;
3131

3232
// Reference storage for heap types: string, byte[], List<KVObject>, Dictionary<string, KVObject>, etc.
33-
internal object _ref;
33+
internal readonly object _ref;
3434

3535
/// <summary>
3636
/// Gets a value indicating whether this value is null.

0 commit comments

Comments
 (0)