Make DecodeOneUtf8CodePoint* take |const EndIter& aEnd| to enforce immutability of the end iterator. No bug, r=me as trivial
authorJeff Walden <jwalden@mit.edu>
Thu, 09 Aug 2018 21:04:23 -0700
changeset 486420 ed645e2703e989bd2cb7971162d06fef54d7daf2
parent 486419 f244ce374cd26b231d5309900b4648db90ad39cb
child 486421 77038440246afb2d878f129dffd4b7c2af6b38ec
push id9719
push userffxbld-merge
push dateFri, 24 Aug 2018 17:49:46 +0000
treeherdermozilla-beta@719ec98fba77 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersme
milestone63.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Make DecodeOneUtf8CodePoint* take |const EndIter& aEnd| to enforce immutability of the end iterator. No bug, r=me as trivial
mfbt/Utf8.h
--- a/mfbt/Utf8.h
+++ b/mfbt/Utf8.h
@@ -258,17 +258,17 @@ inline bool
 IsTrailingUnit(Utf8Unit aUnit)
 {
   return (aUnit.toUint8() & 0b1100'0000) == 0b1000'0000;
 }
 
 /**
  * Given |aLeadUnit| that is a non-ASCII code unit, a pointer to an |Iter aIter|
  * that (initially) itself points one unit past |aLeadUnit|, and
- * |const EndIter aEnd| that denotes the end of the UTF-8 data when compared
+ * |const EndIter& aEnd| that denotes the end of the UTF-8 data when compared
  * against |*aIter| using |aEnd - *aIter|:
  *
  * If |aLeadUnit| and subsequent code units computed using |*aIter| (up to
  * |aEnd|) encode a valid code point -- not exceeding Unicode's range, not a
  * surrogate, in shortest form -- then return Some(that code point) and advance
  * |*aIter| past those code units.
  *
  * Otherwise decrement |*aIter| (so that it points at |aLeadUnit|) and return
@@ -294,17 +294,17 @@ template<typename Iter,
          typename EndIter,
          class OnBadLeadUnit,
          class OnNotEnoughUnits,
          class OnBadTrailingUnit,
          class OnBadCodePoint,
          class OnNotShortestForm>
 MOZ_ALWAYS_INLINE Maybe<char32_t>
 DecodeOneUtf8CodePointInline(const Utf8Unit aLeadUnit,
-                             Iter* aIter, const EndIter aEnd,
+                             Iter* aIter, const EndIter& aEnd,
                              OnBadLeadUnit aOnBadLeadUnit,
                              OnNotEnoughUnits aOnNotEnoughUnits,
                              OnBadTrailingUnit aOnBadTrailingUnit,
                              OnBadCodePoint aOnBadCodePoint,
                              OnNotShortestForm aOnNotShortestForm)
 {
   MOZ_ASSERT(Utf8Unit((*aIter)[-1]) == aLeadUnit);
 
@@ -386,17 +386,17 @@ template<typename Iter,
          typename EndIter,
          class OnBadLeadUnit,
          class OnNotEnoughUnits,
          class OnBadTrailingUnit,
          class OnBadCodePoint,
          class OnNotShortestForm>
 inline Maybe<char32_t>
 DecodeOneUtf8CodePoint(const Utf8Unit aLeadUnit,
-                       Iter* aIter, const EndIter aEnd,
+                       Iter* aIter, const EndIter& aEnd,
                        OnBadLeadUnit aOnBadLeadUnit,
                        OnNotEnoughUnits aOnNotEnoughUnits,
                        OnBadTrailingUnit aOnBadTrailingUnit,
                        OnBadCodePoint aOnBadCodePoint,
                        OnNotShortestForm aOnNotShortestForm)
 {
   return DecodeOneUtf8CodePointInline(aLeadUnit, aIter, aEnd,
                                       aOnBadLeadUnit, aOnNotEnoughUnits,
@@ -409,17 +409,17 @@ DecodeOneUtf8CodePoint(const Utf8Unit aL
  * trailing if-invalid notifier functors.
  *
  * This function is MOZ_ALWAYS_INLINE: if you don't need that, use the version
  * of this function without the "Inline" suffix on the name.
  */
 template<typename Iter, typename EndIter>
 MOZ_ALWAYS_INLINE Maybe<char32_t>
 DecodeOneUtf8CodePointInline(const Utf8Unit aLeadUnit,
-                             Iter* aIter, const EndIter aEnd)
+                             Iter* aIter, const EndIter& aEnd)
 {
   // aOnBadLeadUnit is called when |aLeadUnit| itself is an invalid lead unit in
   // a multi-unit code point.  It is passed no arguments: the caller already has
   // |aLeadUnit| on hand, so no need to provide it again.
   auto onBadLeadUnit = []() {};
 
   // aOnNotEnoughUnits is called when |aLeadUnit| properly indicates a code
   // point length, but there aren't enough units from |*aIter| to |aEnd| to
@@ -461,16 +461,16 @@ DecodeOneUtf8CodePointInline(const Utf8U
 
 /**
  * Identical to the above function, but not forced to be instantiated inline --
  * the compiler/linker are allowed to common up separate invocations.
  */
 template<typename Iter, typename EndIter>
 inline Maybe<char32_t>
 DecodeOneUtf8CodePoint(const Utf8Unit aLeadUnit,
-                       Iter* aIter, const EndIter aEnd)
+                       Iter* aIter, const EndIter& aEnd)
 {
   return DecodeOneUtf8CodePointInline(aLeadUnit, aIter, aEnd);
 }
 
 } // namespace mozilla
 
 #endif /* mozilla_Utf8_h */