I'm curious as to what people think of this source.
Any comments, questions, concerns?
Any comments, questions, concerns?
I have a concern that your packet handler is less efficient than just using a switch. I talked to Hybrid about it too and he said the same thing. I would double check on if that's an appropriate method.Quote:
I'm curious as to what people think of this source.
Any comments, questions, concerns?
Hmm, I had a discussion with Unknownone about it a long long time ago (I've been using this way for a long ass time :P) and he said it was a pretty efficient way to do it.Quote:
I have a concern that your packet handler is less efficient than just using a switch. I talked to Hybrid about it too and he said the same thing. I would double check on if that's an appropriate method.
Well, if you think about it, a switch statement would be much simpler. I can see where a dictionary would be more efficient if the switch contained more than 50 cases, but I can't see it being more efficient with less than 30. (Either way, it's just checking values- but a switch is simpler than a dictionary and possibly more efficient).Quote:
Hmm, I had a discussion with Unknownone about it a long long time ago (I've been using this way for a long ass time :P) and he said it was a pretty efficient way to do it.
I might do some further testing.
public TValue this[TKey key]
{
get
{
int index = this.FindEntry(key);
if (index >= 0)
{
return this.entries[index].value;
}
ThrowHelper.ThrowKeyNotFoundException();
return default(TValue);
}
set
{
this.Insert(key, value, false);
}
}
private int FindEntry(TKey key)
{
if (key == null)
{
ThrowHelper.ThrowArgumentNullException(ExceptionArgument.key);
}
if (this.buckets != null)
{
int num = this.comparer.GetHashCode(key) & 0x7fffffff;
for (int i = this.buckets[num % this.buckets.Length]; i >= 0; i = this.entries[i].next)
{
if ((this.entries[i].hashCode == num) && this.comparer.Equals(this.entries[i].key, key))
{
return i;
}
}
}
return -1;
}
That doesn't loop through all the entries in the dictionary.Quote:
This is how you find the packet processor:
Where a switch case will just take x from y.
Imagine 1000 entries in your dictionary.
What seems faster in your own opinion, looping through all the entries or taking x from y?
A switch case would be much faster IMO.
Quote:
Locating source for 'C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs'. Checksum: MD5 {55 76 a3 37 12 d7 84 65 c8 2 a9 9c 87 9f ce ae}
The file 'C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs' does not exist.
Looking in script documents for 'C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs'...
Looking in the projects for 'C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs'.
The file was not found in a project.
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\crt\src\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\mfc\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\src\atl\'...
Looking in directory 'c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include\'...
The debug source files settings for the active solution indicate that the debugger will not ask the user to find the file: C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs.
The debugger could not locate the source file 'C:\Users\Tyler\Documents\Visual Studio 2010\Projects\KinSocket\KinSocket\Database\MySqlEn gine.cs'
theres a space in the name.Quote:
MySqlEn gine.cs