// Compute hash value for each case label constant and store the hash buckets // into a dictionary indexed by hash value. private static Dictionary <uint, HashBucket> ComputeStringHashMap( KeyValuePair <ConstantValue, object>[] caseLabels, GetStringHashCode computeStringHashcodeDelegate) { Debug.Assert(caseLabels != null); var stringHashMap = new Dictionary <uint, HashBucket>(caseLabels.Length); foreach (var kvPair in caseLabels) { ConstantValue stringConstant = kvPair.Key; Debug.Assert(stringConstant.IsNull || stringConstant.IsString); uint hash = computeStringHashcodeDelegate((string)stringConstant.Value); HashBucket bucket; if (!stringHashMap.TryGetValue(hash, out bucket)) { bucket = new HashBucket(); stringHashMap.Add(hash, bucket); } Debug.Assert(!bucket.Contains(kvPair)); bucket.Add(kvPair); } return(stringHashMap); }
internal SwitchStringJumpTableEmitter( ILBuilder builder, LocalDefinition key, KeyValuePair <ConstantValue, object>[] caseLabels, object fallThroughLabel, LocalDefinition keyHash, EmitStringCompareAndBranch emitStringCondBranchDelegate, GetStringHashCode computeStringHashcodeDelegate) { Debug.Assert(caseLabels.Length > 0); Debug.Assert(emitStringCondBranchDelegate != null); this.builder = builder; this.key = key; this.caseLabels = caseLabels; this.fallThroughLabel = fallThroughLabel; this.keyHash = keyHash; this.emitStringCondBranchDelegate = emitStringCondBranchDelegate; this.computeStringHashcodeDelegate = computeStringHashcodeDelegate; }
internal SwitchStringJumpTableEmitter( ILBuilder builder, LocalOrParameter key, KeyValuePair<ConstantValue, object>[] caseLabels, object fallThroughLabel, LocalDefinition keyHash, EmitStringCompareAndBranch emitStringCondBranchDelegate, GetStringHashCode computeStringHashcodeDelegate) { Debug.Assert(caseLabels.Length > 0); Debug.Assert(emitStringCondBranchDelegate != null); _builder = builder; _key = key; _caseLabels = caseLabels; _fallThroughLabel = fallThroughLabel; _keyHash = keyHash; _emitStringCondBranchDelegate = emitStringCondBranchDelegate; _computeStringHashcodeDelegate = computeStringHashcodeDelegate; }
internal SwitchStringJumpTableEmitter( ILBuilder builder, LocalOrParameter key, KeyValuePair <ConstantValue, object>[] caseLabels, object fallThroughLabel, LocalDefinition?keyHash, EmitStringCompareAndBranch emitStringCondBranchDelegate, GetStringHashCode computeStringHashcodeDelegate) { Debug.Assert(caseLabels.Length > 0); RoslynDebug.Assert(emitStringCondBranchDelegate != null); _builder = builder; _key = key; _caseLabels = caseLabels; _fallThroughLabel = fallThroughLabel; _keyHash = keyHash; _emitStringCondBranchDelegate = emitStringCondBranchDelegate; _computeStringHashcodeDelegate = computeStringHashcodeDelegate; }
// Compute hash value for each case label constant and store the hash buckets // into a dictionary indexed by hash value. private static Dictionary<uint, HashBucket> ComputeStringHashMap( KeyValuePair<ConstantValue, object>[] caseLabels, GetStringHashCode computeStringHashcodeDelegate) { Debug.Assert(caseLabels != null); var stringHashMap = new Dictionary<uint, HashBucket>(caseLabels.Length); foreach (var kvPair in caseLabels) { ConstantValue stringConstant = kvPair.Key; Debug.Assert(stringConstant.IsNull || stringConstant.IsString); uint hash = computeStringHashcodeDelegate((string)stringConstant.Value); HashBucket bucket; if (!stringHashMap.TryGetValue(hash, out bucket)) { bucket = new HashBucket(); stringHashMap.Add(hash, bucket); } Debug.Assert(!bucket.Contains(kvPair)); bucket.Add(kvPair); } return stringHashMap; }