String interning when string caching is disabled
BrettShearer
Posts: 5
Hi - I assume that the following method is the code that extracts the encoded/compressed resource strings or strings in general.
I can see that this is interning the result string (str2). If this is the case, why is the static hashtable required.
public static string Get(int #05b)
{
#05b -= #Z5b;
if (#Y5b)
{
string str = (string) #z5b[#05b];
if (str != null)
{
return str;
}
}
int count = 0;
int index = #05b;
int num3 = #Xp[index++];
if ((num3 & 0x80) == 0)
{
count = num3;
if (count == 0)
{
return string.Empty;
}
}
else if ((num3 & 0x40) == 0)
{
count = ((num3 & 0x3f) << 8) + #Xp[index++];
}
else
{
count = ((((num3 & 0x1f) << 0x18) + (#Xp[index++] << 0x10)) + (#Xp[index++] << 8)) + #Xp[index++];
}
try
{
byte[] bytes = Convert.FromBase64String(Encoding.UTF8.GetString(#Xp, index, count));
string str2 = string.Intern(Encoding.UTF8.GetString(bytes, 0, bytes.Length));
if (#Y5b)
{
try
{
#z5b.Add(#05b, str2);
}
catch
{
}
}
return str2;
}
catch
{
return null;
}
}
I can see that this is interning the result string (str2). If this is the case, why is the static hashtable required.
public static string Get(int #05b)
{
#05b -= #Z5b;
if (#Y5b)
{
string str = (string) #z5b[#05b];
if (str != null)
{
return str;
}
}
int count = 0;
int index = #05b;
int num3 = #Xp[index++];
if ((num3 & 0x80) == 0)
{
count = num3;
if (count == 0)
{
return string.Empty;
}
}
else if ((num3 & 0x40) == 0)
{
count = ((num3 & 0x3f) << 8) + #Xp[index++];
}
else
{
count = ((((num3 & 0x1f) << 0x18) + (#Xp[index++] << 0x10)) + (#Xp[index++] << 8)) + #Xp[index++];
}
try
{
byte[] bytes = Convert.FromBase64String(Encoding.UTF8.GetString(#Xp, index, count));
string str2 = string.Intern(Encoding.UTF8.GetString(bytes, 0, bytes.Length));
if (#Y5b)
{
try
{
#z5b.Add(#05b, str2);
}
catch
{
}
}
return str2;
}
catch
{
return null;
}
}
Comments
Was there a specific reason you were asking?
Redgate Software
Redgate Software