Bug 1499212 remove mention of character pointers in docs for Literal methods r=dbaron
authorKarl Tomlinson <karlt+@karlt.net>
Tue, 16 Oct 2018 21:07:20 +0000
changeset 490415 5463ea36a953009a99dded33078b79f7c45b38aa
parent 490414 0f7592b662e27238b8ebc442fa755e5e891cdef9
child 490416 386c46fc6e8dce5760f74427c125a63261c4b908
push id247
push userfmarier@mozilla.com
push dateSat, 27 Oct 2018 01:06:44 +0000
reviewersdbaron
bugs1499212
milestone64.0a1
Bug 1499212 remove mention of character pointers in docs for Literal methods r=dbaron Since https://hg.mozilla.org/mozilla-central/rev/9db7cf4cc385#l13.44 the type system always excludes calls with character pointers and so there is no need to mention this in the comment. The comment for the 8-bit to 16-bit AssignLiteral overload is modified a little to use "char" instead of "character" so as not to imply that anything other than 8-bit char parameters may be provided to that overload. The ReplaceLiteral and InsertLiteral comments are adjusted to use "character" instead of "char" so as not to imply that the method or comment is limited to 8-bit char parameters. Differential Revision: https://phabricator.services.mozilla.com/D8770
xpcom/string/nsTStringRepr.h
xpcom/string/nsTSubstring.h
--- a/xpcom/string/nsTStringRepr.h
+++ b/xpcom/string/nsTStringRepr.h
@@ -254,18 +254,18 @@ public:
   bool NS_FASTCALL EqualsASCII(const char* aData, size_type aLen) const;
   // An efficient comparison with ASCII that can be used even
   // for wide strings. Call this version when 'data' is
   // null-terminated.
   bool NS_FASTCALL EqualsASCII(const char* aData) const;
 
   // EqualsLiteral must ONLY be applied to an actual literal string, or
   // a char array *constant* declared without an explicit size.
-  // Do not attempt to use it with a regular char* pointer, or with a
-  // non-constant char array variable. Use EqualsASCII for them.
+  // Do not attempt to use it with a non-constant char array variable.
+  // Use EqualsASCII for that.
   // The template trick to acquire the array length at compile time without
   // using a macro is due to Corey Kosak, with much thanks.
   template<int N>
   inline bool EqualsLiteral(const char (&aStr)[N]) const
   {
     return EqualsASCII(aStr, N - 1);
   }
 
@@ -276,19 +276,18 @@ public:
   // uppercase character, it is guaranteed to return false. We will
   // throw assertions too.
   bool NS_FASTCALL LowerCaseEqualsASCII(const char* aData,
                                         size_type aLen) const;
   bool NS_FASTCALL LowerCaseEqualsASCII(const char* aData) const;
 
   // LowerCaseEqualsLiteral must ONLY be applied to an actual
   // literal string, or a char array *constant* declared without an
-  // explicit size.  Do not attempt to use it with a regular char*
-  // pointer, or with a non-constant char array variable. Use
-  // LowerCaseEqualsASCII for them.
+  // explicit size.  Do not attempt to use it with a non-constant char array
+  // variable. Use LowerCaseEqualsASCII for that.
   template<int N>
   bool LowerCaseEqualsLiteral(const char (&aStr)[N]) const
   {
     return LowerCaseEqualsASCII(aStr, N - 1);
   }
 
   // Returns true if this string overlaps with the given string fragment.
   bool IsDependentOn(const char_type* aStart, const char_type* aEnd) const
--- a/xpcom/string/nsTSubstring.h
+++ b/xpcom/string/nsTSubstring.h
@@ -470,34 +470,34 @@ public:
   {
     return AssignASCII(aData,
                        mozilla::AssertedCast<size_type, size_t>(strlen(aData)),
                        aFallible);
   }
 
   // AssignLiteral must ONLY be applied to an actual literal string, or
   // a character array *constant* declared without an explicit size.
-  // Do not attempt to use it with a regular character pointer, or with a
-  // non-constant chararacter array variable. Use AssignASCII for those.
+  // Do not attempt to use it with a non-constant character array variable.
+  // Use AssignASCII for that.
   //
   // This method does not need a fallible version, because it uses the
   // POD buffer of the literal as the string's buffer without allocating.
   // The literal does not need to be ASCII. If this a 16-bit string, this
   // method takes a u"" literal. (The overload on 16-bit strings that takes
   // a "" literal takes only ASCII.)
   template<int N>
   void AssignLiteral(const char_type (&aStr)[N])
   {
     AssignLiteral(aStr, N - 1);
   }
 
   // AssignLiteral must ONLY be applied to an actual literal string, or
-  // a character array *constant* declared without an explicit size.
-  // Do not attempt to use it with a regular character pointer, or with a
-  // non-constant chararacter array variable. Use AssignASCII for those.
+  // a char array *constant* declared without an explicit size.
+  // Do not attempt to use it with a non-constant char array variable.
+  // Use AssignASCII for that.
   //
   // This method takes an 8-bit (ASCII-only!) string that is expanded
   // into a 16-bit string at run time causing a run-time allocation.
   // To avoid the run-time allocation (at the cost of the literal
   // taking twice the size in the binary), use the above overload that
   // takes a u"" string instead. Using the overload that takes a u""
   // literal is generally preferred when working with 16-bit strings.
   //
@@ -588,18 +588,18 @@ public:
                                 size_type aLength = size_type(-1));
 
   MOZ_MUST_USE bool NS_FASTCALL ReplaceASCII(index_type aCutStart, size_type aCutLength,
                                              const char* aData,
                                              size_type aLength,
                                              const fallible_t&);
 
   // ReplaceLiteral must ONLY be applied to an actual literal string.
-  // Do not attempt to use it with a regular char* pointer, or with a char
-  // array variable. Use Replace or ReplaceASCII for those.
+  // Do not attempt to use it with a character array variable.
+  // Use Replace or ReplaceASCII for that.
   template<int N>
   void ReplaceLiteral(index_type aCutStart, size_type aCutLength,
                       const char_type (&aStr)[N])
   {
     ReplaceLiteral(aCutStart, aCutLength, aStr, N - 1);
   }
 
   void Append(char_type aChar);
@@ -636,18 +636,18 @@ public:
   MOZ_MUST_USE bool AppendASCII(const char* aData,
                                 size_type aLength,
                                 const fallible_t& aFallible);
 
   // Appends a literal string ("" literal in the 8-bit case and u"" literal
   // in the 16-bit case) to the string.
   //
   // AppendLiteral must ONLY be applied to an actual literal string.
-  // Do not attempt to use it with a regular character pointer, or with a
-  // character array variable. Use Append or AppendASCII for those.
+  // Do not attempt to use it with a character array variable.
+  // Use Append or AppendASCII for that.
   template<int N>
   void AppendLiteral(const char_type (&aStr)[N])
   {
     // The case where base_string_type::mLength is zero is intentionally
     // left unoptimized (could be optimized as call to AssignLiteral),
     // because it's rare/nonexistent. If you add that optimization,
     // please be sure to also check that
     // !(base_string_type::mDataFlags & DataFlags::REFCOUNTED)
@@ -797,18 +797,18 @@ public:
     Replace(aPos, 0, aStr);
   }
   void Insert(const substring_tuple_type& aTuple, index_type aPos)
   {
     Replace(aPos, 0, aTuple);
   }
 
   // InsertLiteral must ONLY be applied to an actual literal string.
-  // Do not attempt to use it with a regular char* pointer, or with a char
-  // array variable. Use Insert for those.
+  // Do not attempt to use it with a character array variable.
+  // Use Insert for that.
   template<int N>
   void InsertLiteral(const char_type (&aStr)[N], index_type aPos)
   {
     ReplaceLiteral(aPos, 0, aStr, N - 1);
   }
 
   void Cut(index_type aCutStart, size_type aCutLength)
   {