Add ContainsIgnoreCase helper to reduce string alloc, cleanup

This commit is contained in:
Sinai
2021-04-30 23:43:27 +10:00
parent 74ff1d8f01
commit d76bc1f812
8 changed files with 34 additions and 21 deletions

View File

@ -59,7 +59,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
string displayName = Utility.SignatureHighlighter.ParseFullSyntax(type, true);
string fullName = RuntimeProvider.Instance.Reflection.GetDeobfuscatedType(type).FullName;
string filteredName = fullName.ToLower();
string filteredName = fullName;
list.Add(new CachedType
{
@ -89,7 +89,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
timeOfLastCheck = Time.time;
value = value?.ToLower() ?? "";
value = value ?? "";
if (string.IsNullOrEmpty(value))
{
@ -118,7 +118,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
if (added.Contains(entry.FullNameValue))
continue;
if (entry.FullNameForFilter.Contains(value))
if (entry.FullNameForFilter.ContainsIgnoreCase(value))
AddToDict(entry);
added.Add(entry.FullNameValue);

View File

@ -25,7 +25,7 @@ namespace UnityExplorer.UI.Widgets
public string CurrentFilter
{
get => currentFilter;
set => currentFilter = value?.ToLower() ?? "";
set => currentFilter = value ?? "";
}
private string currentFilter;

View File

@ -13,8 +13,6 @@ namespace UnityExplorer.UI.Widgets
public int InstanceID { get; private set; }
public CachedTransform Parent { get; internal set; }
//public string Name { get; internal set; }
//public int ChildCount { get; internal set; }
public int Depth { get; internal set; }
public bool Expanded => Tree.IsCellExpanded(InstanceID);
@ -24,15 +22,13 @@ namespace UnityExplorer.UI.Widgets
Tree = tree;
Value = transform;
Parent = parent;
InstanceID = transform.GetInstanceID();
Update(transform, depth);
}
public void Update(Transform transform, int depth)
{
Value = transform;
InstanceID = transform.GetInstanceID();
//Name = Value.name;
//ChildCount = Value.childCount;
Depth = depth;
}
}

View File

@ -22,7 +22,7 @@ namespace UnityExplorer.UI.Widgets
get => currentFilter;
set
{
currentFilter = value?.ToLower() ?? "";
currentFilter = value ?? "";
if (!wasFiltering && Filtering)
wasFiltering = true;
else if (wasFiltering && !Filtering)
@ -133,7 +133,7 @@ namespace UnityExplorer.UI.Widgets
private bool FilterHierarchy(Transform obj)
{
if (obj.name.ToLower().Contains(currentFilter))
if (obj.name.ContainsIgnoreCase(currentFilter))
return true;
if (obj.childCount <= 0)
@ -146,10 +146,8 @@ namespace UnityExplorer.UI.Widgets
return false;
}
public void SetCell(TransformCell iCell, int index)
public void SetCell(TransformCell cell, int index)
{
var cell = iCell as TransformCell;
if (index < displayedObjects.Count)
cell.ConfigureCell(displayedObjects[index], index);
else