Browse Source

Binding.Util: Minor perf-op

tags/v0.12
Eli Belash 6 years ago
parent
commit
854c2e5251
1 changed files with 7 additions and 2 deletions
  1. +7
    -2
      src/TensorFlowNET.Core/Binding.Util.cs

+ 7
- 2
src/TensorFlowNET.Core/Binding.Util.cs View File

@@ -178,13 +178,18 @@ namespace Tensorflow

public static IEnumerable<(TKey, TValue)> enumerate<TKey, TValue>(KeyValuePair<TKey, TValue>[] values)
{
foreach (var item in values)
var len = values.Length;
for (var i = 0; i < len; i++)
{
var item = values[i];
yield return (item.Key, item.Value);
}
}

public static IEnumerable<(int, T)> enumerate<T>(IList<T> values)
{
for (int i = 0; i < values.Count; i++)
var len = values.Count;
for (int i = 0; i < len; i++)
yield return (i, values[i]);
}



Loading…
Cancel
Save