瀏覽代碼

Couple tweaks to CoreTable

Kenric Nugteren 3 月之前
父節點
當前提交
517d64b4ac
共有 2 個文件被更改,包括 5 次插入5 次删除
  1. 3 3
      InABox.Core/CoreTable/CoreRow.cs
  2. 2 2
      InABox.Core/CoreTable/CoreTable.cs

+ 3 - 3
InABox.Core/CoreTable/CoreRow.cs

@@ -294,10 +294,10 @@ namespace InABox.Core
 
         private int GetColumn(string columnname)
         {
-            if (_columnindexes.ContainsKey(columnname))
-                return _columnindexes[columnname];
+            if (_columnindexes.TryGetValue(columnname, out var index))
+                return index;
 
-            var index = Table.GetColumnIndex(columnname);
+            index = Table.GetColumnIndex(columnname);
             _columnindexes[columnname] = index;
             return index;
         }

+ 2 - 2
InABox.Core/CoreTable/CoreTable.cs

@@ -231,7 +231,7 @@ namespace InABox.Core
         {
             var result = new Dictionary<TKey, TValue>();
             var sorted = sort == null ? Rows : Rows.OrderBy(x => x.Get(sort)).ToList();
-            foreach (var row in Rows)
+            foreach (var row in sorted)
                 result[row.Get(key)] = row.Get(value);
             return result;
         }
@@ -241,7 +241,7 @@ namespace InABox.Core
         {
             var result = new Dictionary<TKey, string>();
             var sorted = sort == null ? Rows : Rows.OrderBy(x => x.Get(sort)).ToList();
-            foreach (var row in Rows)
+            foreach (var row in sorted)
             {
                 var display = new List<object>();
                 foreach (var value in values)