Replace for(;;) with while (true).

This commit is contained in:
Paul Chote
2019-06-08 15:17:27 +01:00
committed by reaperrr
parent 4d8aaeb690
commit c253aaeb9d
9 changed files with 13 additions and 9 deletions

View File

@@ -164,7 +164,11 @@ namespace OpenRA
public static IEnumerable<T> Iterate<T>(this T t, Func<T, T> f) public static IEnumerable<T> Iterate<T>(this T t, Func<T, T> f)
{ {
for (;;) { yield return t; t = f(t); } while (true)
{
yield return t;
t = f(t);
}
} }
public static T MinBy<T, U>(this IEnumerable<T> ts, Func<T, U> selector) public static T MinBy<T, U>(this IEnumerable<T> ts, Func<T, U> selector)

View File

@@ -42,7 +42,7 @@ namespace OpenRA.FileFormats
var is24Bit = false; var is24Bit = false;
var data = new List<byte>(); var data = new List<byte>();
for (;;) while (true)
{ {
var length = IPAddress.NetworkToHostOrder(s.ReadInt32()); var length = IPAddress.NetworkToHostOrder(s.ReadInt32());
var type = Encoding.UTF8.GetString(s.ReadBytes(4)); var type = Encoding.UTF8.GetString(s.ReadBytes(4));

View File

@@ -233,7 +233,7 @@ namespace OpenRA
var maxKeepAlive = 5000 / emptyDelay; var maxKeepAlive = 5000 / emptyDelay;
var keepAlive = maxKeepAlive; var keepAlive = maxKeepAlive;
for (;;) while (true)
{ {
List<MapPreview> todo; List<MapPreview> todo;
lock (syncRoot) lock (syncRoot)

View File

@@ -177,7 +177,7 @@ namespace OpenRA.Network
clientId = reader.ReadInt32(); clientId = reader.ReadInt32();
connectionState = ConnectionState.Connected; connectionState = ConnectionState.Connected;
for (;;) while (true)
{ {
var len = reader.ReadInt32(); var len = reader.ReadInt32();
var client = reader.ReadInt32(); var client = reader.ReadInt32();

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Server
var rx = new byte[1024]; var rx = new byte[1024];
var len = 0; var len = 0;
for (;;) while (true)
{ {
try try
{ {

View File

@@ -172,7 +172,7 @@ namespace OpenRA.Server
Log.Write("server", "Initial mod: {0}", ModData.Manifest.Id); Log.Write("server", "Initial mod: {0}", ModData.Manifest.Id);
Log.Write("server", "Initial map: {0}", LobbyInfo.GlobalSettings.Map); Log.Write("server", "Initial map: {0}", LobbyInfo.GlobalSettings.Map);
for (;;) while (true)
{ {
var checkRead = new List<Socket>(); var checkRead = new List<Socket>();
if (State == ServerState.WaitingPlayers) if (State == ServerState.WaitingPlayers)

View File

@@ -167,7 +167,7 @@ namespace OpenRA.Mods.Common.Widgets
Func<CPos, CVec, CPos> findEdge = (refCell, direction) => Func<CPos, CVec, CPos> findEdge = (refCell, direction) =>
{ {
for (;;) while (true)
{ {
var newCell = refCell + direction; var newCell = refCell + direction;
if (!shouldPaint(newCell)) if (!shouldPaint(newCell))

View File

@@ -164,7 +164,7 @@ namespace OpenRA.Mods.Common
public static IEnumerable<CPos> RandomWalk(CPos p, MersenneTwister r) public static IEnumerable<CPos> RandomWalk(CPos p, MersenneTwister r)
{ {
for (;;) while (true)
{ {
var dx = r.Next(-1, 2); var dx = r.Next(-1, 2);
var dy = r.Next(-1, 2); var dy = r.Next(-1, 2);

View File

@@ -109,7 +109,7 @@ namespace OpenRA.Mods.Common.Widgets
lock (syncWorker) lock (syncWorker)
workerAlive = true; workerAlive = true;
for (;;) while (true)
{ {
float hue; float hue;
lock (syncWorker) lock (syncWorker)