Use Math.DivRem in another place in mscorlib
authorStephen Toub <stoub@microsoft.com>
Tue, 15 Nov 2016 14:36:38 +0000 (09:36 -0500)
committerStephen Toub <stoub@microsoft.com>
Tue, 15 Nov 2016 14:36:38 +0000 (09:36 -0500)
Went through all uses of % looking for places DivRem could be used.  This looks like it's the only one of note.

src/mscorlib/src/System/Globalization/IdnMapping.cs

index cbc0e79..7881ac4 100644 (file)
@@ -710,8 +710,10 @@ namespace System.Globalization
                                             k >= bias + tmax ? tmax : k - bias;
                                     if (q < t) break;
                                     Contract.Assert(punycodeBase != t, "[IdnMapping.punycode_encode]Expected punycodeBase (36) to be != t");
-                                    output.Append(encode_digit(t + (q - t) % (punycodeBase - t)));
-                                    q = (q - t) / (punycodeBase - t);
+
+                                    int mod;
+                                    q = Math.DivRem(q - t, punycodeBase - t, out mod);
+                                    output.Append(encode_digit(t + mod));
                                 }
 
                                 output.Append(encode_digit(q));