CompoundTag indexer using tag names implemented

This commit is contained in:
ForeverZer0 2021-08-24 20:45:10 -04:00
parent 22aef3be81
commit 36bbe4844a
1 changed files with 8 additions and 2 deletions

View File

@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using System.Text;
using JetBrains.Annotations;
@ -69,7 +68,7 @@ namespace SharpNBT
{
foreach (var tag in this)
{
if (name.Equals(tag.Name))
if (string.CompareOrdinal(name, tag.Name) == 0)
return tag;
if (deep && tag is CompoundTag child)
@ -83,6 +82,13 @@ namespace SharpNBT
return null;
}
/// <summary>
/// Retrieves a child tag with the specified <paramref name="name"/>, or <see langword="null"/> if no match was found.
/// </summary>
/// <param name="name">The name of the tag to retrieve.</param>
[CanBeNull]
public Tag this[[NotNull] string name] => Find(name, false);
/// <inheritdoc cref="Tag.PrettyPrinted(StringBuilder,int,string)"/>
protected internal override void PrettyPrinted(StringBuilder buffer, int level, string indent)
{