Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZoltan Varga <vargaz@gmail.com>2019-06-07 06:03:22 +0300
committerGitHub <noreply@github.com>2019-06-07 06:03:22 +0300
commitbd1ad0089f16770a0046f5c0415f072bc3c480bb (patch)
treec6ec568971f25d5fa35dc4e18dcc094d94209336 /mcs/class/referencesource
parent03c6855d05250ff7fe8d105d6e56138d60807ff4 (diff)
Switch Hashtables to Dictionary in the encoding classes so Hashtable can be linked out. (#14774)
Diffstat (limited to 'mcs/class/referencesource')
-rw-r--r--mcs/class/referencesource/mscorlib/system/text/encoding.cs19
1 files changed, 8 insertions, 11 deletions
diff --git a/mcs/class/referencesource/mscorlib/system/text/encoding.cs b/mcs/class/referencesource/mscorlib/system/text/encoding.cs
index 38b44bf8cd6..efa74587c90 100644
--- a/mcs/class/referencesource/mscorlib/system/text/encoding.cs
+++ b/mcs/class/referencesource/mscorlib/system/text/encoding.cs
@@ -6,7 +6,6 @@
namespace System.Text
{
using System;
- using System.Collections;
using System.Collections.Generic;
using System.Runtime;
using System.Runtime.Remoting;
@@ -107,7 +106,7 @@ namespace System.Text
#if FEATURE_LATIN1
private static volatile Encoding latin1Encoding;
#endif
- static volatile Hashtable encodings;
+ static volatile Dictionary<int, Encoding> encodings;
//
// The following values are from mlang.idl. These values
@@ -440,9 +439,8 @@ namespace System.Text
// Our Encoding
// See if we have a hash table with our encoding in it already.
- if (encodings != null) {
- result = (Encoding)encodings[codepage];
- }
+ if (encodings != null)
+ encodings.TryGetValue (codepage, out result);
if (result == null)
{
@@ -451,12 +449,11 @@ namespace System.Text
{
// Need a new hash table
// in case another thread beat us to creating the Dictionary
- if (encodings == null) {
- encodings = new Hashtable();
- }
+ if (encodings == null)
+ encodings = new Dictionary<int, Encoding> ();
// Double check that we don't have one in the table (in case another thread beat us here)
- if ((result = (Encoding)encodings[codepage]) != null)
+ if (encodings.TryGetValue (codepage, out result))
return result;
// Special case the commonly used Encoding classes here, then call
@@ -552,8 +549,8 @@ namespace System.Text
break;
default:
result = (Encoding)(EncodingHelper.InvokeI18N ("GetEncoding", codepage));
- if (result == null)
- throw new NotSupportedException(string.Format("Encoding {0} data could not be found. Make sure you have correct international codeset assembly installed and enabled.", codepage));
+ if (result == null)
+ throw new NotSupportedException(string.Format("Encoding {0} data could not be found. Make sure you have correct international codeset assembly installed and enabled.", codepage));
break;
}
#else