I have a dictionary right now that is using a string
as the Key, and a GameObject
as the value.
The strings are all IP address's, so they are not very long. Here is an example:
string ip = "192.68.137.1"
I know that number comparisons are much faster than strings, and I am able to parse the IP address's in my database server.
Would it be faster to use an integer array as the KEY for the dictionary? Like this:
int[] ip = { 192, 168, 137, 1 }
I am checking if the dictionary contains certain values on a regular basis, and also adding to the dictionary regularly (At least once a second normally).
The reason that I am confused about this is because the strings that I am using (the IP address's) are always going to be around that length, so would there be any real benefit to using an integer array? If the dictionary would have to loop through 4 numbers every time, I don't know how much faster that is than a string comparison.