Code cleanup / fixes

feature-optimized-md5
Inga 🏳‍🌈 8 years ago
parent e2f109d1b9
commit 4bc3e45b8d
  1. 97
      WhiteRabbit/Flattener.cs

@ -25,17 +25,17 @@
// Fast hard-coded implementation for 3 words // Fast hard-coded implementation for 3 words
private static IEnumerable<T[]> Flatten3<T>(T[][] phrase) private static IEnumerable<T[]> Flatten3<T>(T[][] phrase)
{ {
for (var i0 = 0; i0 < phrase[0].Length; i0++) foreach (var item0 in phrase[0])
{ {
for (var i1 = 0; i1 < phrase[1].Length; i1++) foreach (var item1 in phrase[1])
{ {
for (var i2 = 0; i2 < phrase[2].Length; i2++) foreach (var item2 in phrase[2])
{ {
yield return new T[] yield return new T[]
{ {
phrase[0][i0], item0,
phrase[1][i1], item1,
phrase[2][i2], item2,
}; };
} }
} }
@ -45,20 +45,20 @@
// Fast hard-coded implementation for 4 words // Fast hard-coded implementation for 4 words
private static IEnumerable<T[]> Flatten4<T>(T[][] phrase) private static IEnumerable<T[]> Flatten4<T>(T[][] phrase)
{ {
for (var i0 = 0; i0 < phrase[0].Length; i0++) foreach (var item0 in phrase[0])
{ {
for (var i1 = 0; i1 < phrase[1].Length; i1++) foreach (var item1 in phrase[1])
{ {
for (var i2 = 0; i2 < phrase[2].Length; i2++) foreach (var item2 in phrase[2])
{ {
for (var i3 = 0; i3 < phrase[3].Length; i3++) foreach (var item3 in phrase[3])
{ {
yield return new T[] yield return new T[]
{ {
phrase[0][i0], item0,
phrase[1][i1], item1,
phrase[2][i2], item2,
phrase[3][i3], item3,
}; };
} }
} }
@ -69,23 +69,23 @@
// Fast hard-coded implementation for 5 words // Fast hard-coded implementation for 5 words
private static IEnumerable<T[]> Flatten5<T>(T[][] phrase) private static IEnumerable<T[]> Flatten5<T>(T[][] phrase)
{ {
for (var i0 = 0; i0 < phrase[0].Length; i0++) foreach (var item0 in phrase[0])
{ {
for (var i1 = 0; i1 < phrase[1].Length; i1++) foreach (var item1 in phrase[1])
{ {
for (var i2 = 0; i2 < phrase[2].Length; i2++) foreach (var item2 in phrase[2])
{ {
for (var i3 = 0; i3 < phrase[3].Length; i3++) foreach (var item3 in phrase[3])
{ {
for (var i4 = 0; i4 < phrase[4].Length; i4++) foreach (var item4 in phrase[4])
{ {
yield return new T[] yield return new T[]
{ {
phrase[0][i0], item0,
phrase[1][i1], item1,
phrase[2][i2], item2,
phrase[3][i3], item3,
phrase[4][i4], item4,
}; };
} }
} }
@ -97,25 +97,26 @@
// Fast hard-coded implementation for 6 words // Fast hard-coded implementation for 6 words
private static IEnumerable<T[]> Flatten6<T>(T[][] phrase) private static IEnumerable<T[]> Flatten6<T>(T[][] phrase)
{ {
for (var i0 = 0; i0 < phrase[0].Length; i0++) foreach (var item0 in phrase[0])
{ {
for (var i1 = 0; i1 < phrase[1].Length; i1++) foreach (var item1 in phrase[1])
{ {
for (var i2 = 0; i2 < phrase[2].Length; i2++) foreach (var item2 in phrase[2])
{ {
for (var i3 = 0; i3 < phrase[3].Length; i3++) foreach (var item3 in phrase[3])
{ {
for (var i4 = 0; i4 < phrase[4].Length; i4++) foreach (var item4 in phrase[4])
{ {
for (var i5 = 0; i5 < phrase[5].Length; i5++) foreach (var item5 in phrase[5])
{ {
yield return new T[] yield return new T[]
{ {
phrase[0][i0], item0,
phrase[1][i1], item1,
phrase[2][i2], item2,
phrase[3][i3], item3,
phrase[4][i4], item4,
item5,
}; };
} }
} }
@ -128,27 +129,29 @@
// Fast hard-coded implementation for 7 words // Fast hard-coded implementation for 7 words
private static IEnumerable<T[]> Flatten7<T>(T[][] phrase) private static IEnumerable<T[]> Flatten7<T>(T[][] phrase)
{ {
for (var i0 = 0; i0 < phrase[0].Length; i0++) foreach (var item0 in phrase[0])
{ {
for (var i1 = 0; i1 < phrase[1].Length; i1++) foreach (var item1 in phrase[1])
{ {
for (var i2 = 0; i2 < phrase[2].Length; i2++) foreach (var item2 in phrase[2])
{ {
for (var i3 = 0; i3 < phrase[3].Length; i3++) foreach (var item3 in phrase[3])
{ {
for (var i4 = 0; i4 < phrase[4].Length; i4++) foreach (var item4 in phrase[4])
{ {
for (var i5 = 0; i5 < phrase[5].Length; i5++) foreach (var item5 in phrase[5])
{ {
for (var i6 = 0; i6 < phrase[6].Length; i6++) foreach (var item6 in phrase[6])
{ {
yield return new T[] yield return new T[]
{ {
phrase[0][i0], item0,
phrase[1][i1], item1,
phrase[2][i2], item2,
phrase[3][i3], item3,
phrase[4][i4], item4,
item5,
item6,
}; };
} }
} }

Loading…
Cancel
Save