Bug 965783 - part 1 - convert {Min,Max}Int uses in mozTXTToHTMLConv.cpp to std::{min,max}; r=jduell
authorNathan Froyd <froydnj@mozilla.com>
Thu, 30 Jan 2014 09:55:50 -0500
changeset 166870 c15405b8e593a311e59481d3f14b6d72d4d8bb34
parent 166869 3e1c8c8f5d0ff1a56afc646c9363513e439855b1
child 166871 cffc1c5928e51e84ed4d9ed9572df6858d3f9f12
push id4853
push usercbook@mozilla.com
push dateWed, 05 Feb 2014 13:54:35 +0000
treeherderfx-team@0965914f979c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjduell
bugs965783
milestone30.0a1
Bug 965783 - part 1 - convert {Min,Max}Int uses in mozTXTToHTMLConv.cpp to std::{min,max}; r=jduell
netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
--- a/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
+++ b/netwerk/streamconv/converters/mozTXTToHTMLConv.cpp
@@ -5,16 +5,18 @@
 
 #include "mozTXTToHTMLConv.h"
 #include "nsNetUtil.h"
 #include "nsUnicharUtils.h"
 #include "nsCRT.h"
 #include "nsIExternalProtocolHandler.h"
 #include "nsIIOService.h"
 
+#include <algorithm>
+
 #ifdef DEBUG_BenB_Perf
 #include "prtime.h"
 #include "prinrval.h"
 #endif
 
 const double growthRate = 1.2;
 
 // Bug 183111, editor now replaces multiple spaces with leading
@@ -108,32 +110,32 @@ mozTXTToHTMLConv::UnescapeStr(const char
 {
   const char16_t * subString = nullptr;
   for (uint32_t i = aStartPos; int32_t(i) - aStartPos < aLength;)
   {
     int32_t remainingChars = i - aStartPos;
     if (aInString[i] == '&')
     {
       subString = &aInString[i];
-      if (!nsCRT::strncmp(subString, MOZ_UTF16("&lt;"), MinInt(4, aLength - remainingChars)))
+      if (!nsCRT::strncmp(subString, MOZ_UTF16("&lt;"), std::min(4, aLength - remainingChars)))
       {
         aOutString.Append(char16_t('<'));
         i += 4;
       }
-      else if (!nsCRT::strncmp(subString, MOZ_UTF16("&gt;"), MinInt(4, aLength - remainingChars)))
+      else if (!nsCRT::strncmp(subString, MOZ_UTF16("&gt;"), std::min(4, aLength - remainingChars)))
       {
         aOutString.Append(char16_t('>'));
         i += 4;
       }
-      else if (!nsCRT::strncmp(subString, MOZ_UTF16("&amp;"), MinInt(5, aLength - remainingChars)))
+      else if (!nsCRT::strncmp(subString, MOZ_UTF16("&amp;"), std::min(5, aLength - remainingChars)))
       {
         aOutString.Append(char16_t('&'));
         i += 5;
       }
-      else if (!nsCRT::strncmp(subString, MOZ_UTF16("&quot;"), MinInt(6, aLength - remainingChars)))
+      else if (!nsCRT::strncmp(subString, MOZ_UTF16("&quot;"), std::min(6, aLength - remainingChars)))
       {
         aOutString.Append(char16_t('"'));
         i += 6;
       }
       else
       {
         aOutString += aInString[i];
         i++;
@@ -186,17 +188,17 @@ bool
 mozTXTToHTMLConv::FindURLStart(const char16_t * aInString, int32_t aInLength,
                                const uint32_t pos, const modetype check,
                                uint32_t& start)
 {
   switch(check)
   { // no breaks, because end of blocks is never reached
   case RFC1738:
   {
-    if (!nsCRT::strncmp(&aInString[MaxInt(pos - 4, 0)], MOZ_UTF16("<URL:"), 5))
+    if (!nsCRT::strncmp(&aInString[std::max(int32_t(pos - 4), 0)], MOZ_UTF16("<URL:"), 5))
     {
       start = pos + 1;
       return true;
     }
     else
       return false;
   }
   case RFC2396E:
@@ -1057,17 +1059,17 @@ mozTXTToHTMLConv::CiteLevelTXT(const cha
     {
       i++;
       if (int32_t(i) < lineLength && line[i] == ' ')
         i++;
       // sendmail/mbox
       // Placed here for performance increase
       const char16_t * indexString = &line[logLineStart];
            // here, |logLineStart < lineLength| is always true
-      uint32_t minlength = MinInt(6, NS_strlen(indexString));
+      uint32_t minlength = std::min(uint32_t(6), NS_strlen(indexString));
       if (Substring(indexString,
                     indexString+minlength).Equals(Substring(NS_LITERAL_STRING(">From "), 0, minlength),
                                                   nsCaseInsensitiveStringComparator()))
         //XXX RFC2646
         moreCites = false;
       else
       {
         result++;