Core/Refactor: Part 4

This commit is contained in:
hondacrx
2018-05-27 15:40:06 -04:00
parent d94ad385b1
commit 2c3479c6e2
59 changed files with 159 additions and 223 deletions
+1 -1
View File
@@ -359,7 +359,7 @@ namespace System.Collections
internal BitArrayEnumeratorSimple(BitSet bitarray)
{
this._bitarray = bitarray;
_bitarray = bitarray;
_index = -1;
_version = bitarray._version;
}
+1 -1
View File
@@ -49,7 +49,7 @@ namespace Framework.Cryptography
sha.TransformBlock(bytes, 0, bytes.Length, bytes, 0);
}
public void Finish(byte[] data, int length)
public void Finish(byte[] data)
{
sha.TransformFinalBlock(data, 0, data.Length);
+3 -3
View File
@@ -318,7 +318,7 @@ namespace Framework.Database
_database.Execute(update);
}
public List<FileEntry> GetFileList()
List<FileEntry> GetFileList()
{
List<FileEntry> fileList = new List<FileEntry>();
@@ -348,7 +348,7 @@ namespace Framework.Database
return fileList;
}
public Dictionary<string, AppliedFileEntry> ReceiveAppliedFiles()
Dictionary<string, AppliedFileEntry> ReceiveAppliedFiles()
{
Dictionary<string, AppliedFileEntry> map = new Dictionary<string, AppliedFileEntry>();
@@ -402,7 +402,7 @@ namespace Framework.Database
}
}
protected MySqlBase<T> _database;
MySqlBase<T> _database;
}
public class AppliedFileEntry
+1 -1
View File
@@ -22,7 +22,7 @@ namespace Framework.Database
{
public class SQLTransaction
{
public List<MySqlCommand> commands { get; set; }
public List<MySqlCommand> commands { get; }
public SQLTransaction()
{
+2 -2
View File
@@ -602,7 +602,7 @@ namespace Framework.Dynamic
/// <returns></returns>
public TaskContext CancelGroup(uint group)
{
return Dispatch(() => CancelGroup(group));
return Dispatch(() => _owner.CancelGroup(group));
}
/// <summary>
@@ -612,7 +612,7 @@ namespace Framework.Dynamic
/// <returns></returns>
public TaskContext CancelGroupsOf(List<uint> groups)
{
return Dispatch(() => CancelGroupsOf(groups));
return Dispatch(() => _owner.CancelGroupsOf(groups));
}
/// <summary>
+1 -2
View File
@@ -441,12 +441,11 @@ namespace Framework.IO
public byte[] GetData()
{
long pos;
Stream stream = GetCurrentStream();
var data = new byte[stream.Length];
pos = stream.Position;
long pos = stream.Position;
stream.Seek(0, SeekOrigin.Begin);
for (int i = 0; i < data.Length; i++)
data[i] = (byte)stream.ReadByte();
+39 -42
View File
@@ -1002,8 +1002,6 @@ namespace Framework.IO
public static int deflate(z_stream strm, int flush)
{
int old_flush; // value of flush param for previous deflate call
if(strm==null||strm.state==null||flush>Z_BLOCK||flush<0) return Z_STREAM_ERROR;
deflate_state s=(deflate_state)strm.state;
@@ -1020,7 +1018,7 @@ namespace Framework.IO
}
s.strm=strm; // just in case
old_flush=s.last_flush;
int old_flush = s.last_flush;// value of flush param for previous deflate call
s.last_flush=flush;
// Write the header
@@ -1568,57 +1566,56 @@ namespace Framework.IO
// ---------------------------------------------------------------------------
// Optimized version for FASTEST only
static uint longest_match_fast(deflate_state s, uint cur_match)
{
byte[] scan=s.window;
int scan_ind=(int)s.strstart; // current string
int len; // length of current match
int strend_ind=(int)s.strstart+MAX_MATCH;
static uint longest_match_fast(deflate_state s, uint cur_match)
{
byte[] scan = s.window;
int scan_ind = (int) s.strstart; // current string
int strend_ind = (int) s.strstart + MAX_MATCH;
// The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
// It is easy to get rid of this optimization if necessary.
//Assert(s.hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
// The code is optimized for HASH_BITS >= 8 and MAX_MATCH-2 multiple of 16.
// It is easy to get rid of this optimization if necessary.
//Assert(s.hash_bits >= 8 && MAX_MATCH == 258, "Code too clever");
//Assert((uint)s.strstart <= s.window_size-MIN_LOOKAHEAD, "need lookahead");
//Assert((uint)s.strstart <= s.window_size-MIN_LOOKAHEAD, "need lookahead");
//Assert(cur_match < s.strstart, "no future");
//Assert(cur_match < s.strstart, "no future");
byte[] match=s.window;
int match_ind=(int)cur_match;
byte[] match = s.window;
int match_ind = (int) cur_match;
// Return failure if the match length is less than 2:
if(match[match_ind]!=scan[scan_ind]||match[match_ind+1]!=scan[scan_ind+1]) return MIN_MATCH-1;
// Return failure if the match length is less than 2:
if (match[match_ind] != scan[scan_ind] || match[match_ind + 1] != scan[scan_ind + 1]) return MIN_MATCH - 1;
// The check at best_len-1 can be removed because it will be made
// again later. (This heuristic is not always a win.)
// It is not necessary to compare scan[2] and match[2] since they
// are always equal when the other bytes match, given that
// the hash keys are equal and that HASH_BITS >= 8.
scan_ind+=2;
match_ind+=2;
//Assert(scan[scan_ind] == match[match_ind], "match[2]?");
// The check at best_len-1 can be removed because it will be made
// again later. (This heuristic is not always a win.)
// It is not necessary to compare scan[2] and match[2] since they
// are always equal when the other bytes match, given that
// the hash keys are equal and that HASH_BITS >= 8.
scan_ind += 2;
match_ind += 2;
//Assert(scan[scan_ind] == match[match_ind], "match[2]?");
// We check for insufficient lookahead only every 8th comparison;
// the 256th check will be made at strstart+258.
do
{
} while(scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&&
scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&&
scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&&
scan[++scan_ind]==match[++match_ind]&&scan[++scan_ind]==match[++match_ind]&&
scan_ind<strend_ind);
// We check for insufficient lookahead only every 8th comparison;
// the 256th check will be made at strstart+258.
do
{
} while (scan[++scan_ind] == match[++match_ind] && scan[++scan_ind] == match[++match_ind] &&
scan[++scan_ind] == match[++match_ind] && scan[++scan_ind] == match[++match_ind] &&
scan[++scan_ind] == match[++match_ind] && scan[++scan_ind] == match[++match_ind] &&
scan[++scan_ind] == match[++match_ind] && scan[++scan_ind] == match[++match_ind] &&
scan_ind < strend_ind);
//Assert(scan_ind <= (uint)(s.window_size-1), "wild scan");
//Assert(scan_ind <= (uint)(s.window_size-1), "wild scan");
len=MAX_MATCH-(int)(strend_ind-scan_ind);
int len = MAX_MATCH - (int) (strend_ind - scan_ind);// length of current match
if(len<MIN_MATCH) return MIN_MATCH-1;
if (len < MIN_MATCH) return MIN_MATCH - 1;
s.match_start=cur_match;
return (uint)len<=s.lookahead?(uint)len:s.lookahead;
}
s.match_start = cur_match;
return (uint) len <= s.lookahead ? (uint) len : s.lookahead;
}
// ===========================================================================
// ===========================================================================
// Fill the window when the lookahead becomes insufficient.
// Updates strstart and lookahead.
//
+1 -1
View File
@@ -164,7 +164,7 @@ class DBAppender : Appender
abstract class Appender
{
public Appender(byte id, string name, LogLevel level = LogLevel.Disabled, AppenderFlags flags = AppenderFlags.None)
protected Appender(byte id, string name, LogLevel level = LogLevel.Disabled, AppenderFlags flags = AppenderFlags.None)
{
_id = id;
_name = name;
+1 -1
View File
@@ -25,7 +25,7 @@ namespace Framework.Networking
{
public abstract class SSLSocket : ISocket
{
public SSLSocket(Socket socket)
protected SSLSocket(Socket socket)
{
_socket = socket;
_remoteAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;
+1 -1
View File
@@ -23,7 +23,7 @@ namespace Framework.Networking
{
public abstract class SocketBase : ISocket, IDisposable
{
public SocketBase(Socket socket)
protected SocketBase(Socket socket)
{
_socket = socket;
_remoteAddress = ((IPEndPoint)_socket.RemoteEndPoint).Address;
@@ -1186,7 +1186,7 @@ public static partial class Detour
case 5: nx--; ny--; break;
case 6: ny--; break;
case 7: nx++; ny--; break;
};
}
return getTilesAt(nx, ny, tiles, maxTiles);
}
@@ -1001,7 +1001,7 @@ public static partial class Detour
case XM | ZM: return 5;
case ZM: return 6;
case XP | ZM: return 7;
};
}
return 0xff;
}
-2
View File
@@ -23,8 +23,6 @@ public class Singleton<T> where T : class
private static volatile T instance;
private static object syncRoot = new Object();
public Singleton() { }
public static T Instance
{
get
@@ -80,7 +80,7 @@ namespace Framework.Threading
{
while (_queue.Count != 0)
{
T value = _queue.Dequeue();
_queue.Dequeue();
}
_shutdown = true;