Bug 1170072 - Part 1. Make GetCharProps1 as static function. r=jfkthame
authorMakoto Kato <m_kato@ga2.so-net.ne.jp>
Mon, 07 Sep 2015 11:54:46 +0900
changeset 261120 eab3103736eb10c314c55fffdfa8cf9e9f7069e7
parent 261119 48c6a84888d5cee94dcab9d02c0fefd3cab8b646
child 261121 5bc2bf65bcf59e01fed8aa3f5de0c0f7df7b2e77
push id64663
push userm_kato@ga2.so-net.ne.jp
push dateMon, 07 Sep 2015 02:57:05 +0000
treeherdermozilla-inbound@5bc2bf65bcf5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1170072
milestone43.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
Bug 1170072 - Part 1. Make GetCharProps1 as static function. r=jfkthame
gfx/thebes/gfxScriptItemizer.cpp
intl/unicharutil/util/nsUnicodeProperties.cpp
intl/unicharutil/util/nsUnicodeProperties.h
--- a/gfx/thebes/gfxScriptItemizer.cpp
+++ b/gfx/thebes/gfxScriptItemizer.cpp
@@ -110,25 +110,16 @@ gfxScriptItemizer::fixup(int32_t scriptC
 static inline bool
 SameScript(int32_t runScript, int32_t currCharScript)
 {
     return runScript <= MOZ_SCRIPT_INHERITED ||
            currCharScript <= MOZ_SCRIPT_INHERITED ||
            currCharScript == runScript;
 }
 
-// Return whether the char has a mirrored-pair counterpart.
-// NOTE that this depends on the implementation of nsCharProps records in
-// nsUnicodeProperties, and may need to be updated if those structures change
-static inline bool
-HasMirroredChar(uint32_t aCh)
-{
-    return GetCharProps1(aCh).mMirrorOffsetIndex != 0;
-}
-
 gfxScriptItemizer::gfxScriptItemizer(const char16_t *src, uint32_t length)
     : textPtr(src), textLength(length)
 {
     reset();
 }
 
 void
 gfxScriptItemizer::SetText(const char16_t *src, uint32_t length)
--- a/intl/unicharutil/util/nsUnicodeProperties.cpp
+++ b/intl/unicharutil/util/nsUnicodeProperties.cpp
@@ -8,17 +8,17 @@
 
 #include "mozilla/ArrayUtils.h"
 #include "nsCharTraits.h"
 
 #define UNICODE_BMP_LIMIT 0x10000
 #define UNICODE_LIMIT     0x110000
 
 
-const nsCharProps1&
+static const nsCharProps1&
 GetCharProps1(uint32_t aCh)
 {
     if (aCh < UNICODE_BMP_LIMIT) {
         return sCharProp1Values[sCharProp1Pages[0][aCh >> kCharProp1CharBits]]
                                [aCh & ((1 << kCharProp1CharBits) - 1)];
     }
     if (aCh < (kCharProp1MaxPlane + 1) * 0x10000) {
         return sCharProp1Values[sCharProp1Pages[sCharProp1Planes[(aCh >> 16) - 1]]
@@ -125,16 +125,28 @@ nsIUGenCategory::nsUGenCategory sDetaile
 };
 
 uint32_t
 GetMirroredChar(uint32_t aCh)
 {
     return aCh + sMirrorOffsets[GetCharProps1(aCh).mMirrorOffsetIndex];
 }
 
+bool
+HasMirroredChar(uint32_t aCh)
+{
+    return GetCharProps1(aCh).mMirrorOffsetIndex != 0;
+}
+
+uint8_t
+GetCombiningClass(uint32_t aCh)
+{
+    return GetCharProps1(aCh).mCombiningClass;
+}
+
 uint32_t
 GetScriptTagForCode(int32_t aScriptCode)
 {
     // this will safely return 0 for negative script codes, too :)
     if (uint32_t(aScriptCode) > ArrayLength(sScriptCodeToTag)) {
         return 0;
     }
     return sScriptCodeToTag[aScriptCode];
@@ -244,16 +256,31 @@ bool
 IsClusterExtender(uint32_t aCh, uint8_t aCategory)
 {
     return ((aCategory >= HB_UNICODE_GENERAL_CATEGORY_SPACING_MARK &&
              aCategory <= HB_UNICODE_GENERAL_CATEGORY_NON_SPACING_MARK) ||
             (aCh >= 0x200c && aCh <= 0x200d) || // ZWJ, ZWNJ
             (aCh >= 0xff9e && aCh <= 0xff9f));  // katakana sound marks
 }
 
+enum HSType {
+    HST_NONE = 0x00,
+    HST_L    = 0x01,
+    HST_V    = 0x02,
+    HST_T    = 0x04,
+    HST_LV   = 0x03,
+    HST_LVT  = 0x07
+};
+
+static HSType
+GetHangulSyllableType(uint32_t aCh)
+{
+    return HSType(GetCharProps1(aCh).mHangulType);
+}
+
 void
 ClusterIterator::Next()
 {
     if (AtEnd()) {
         NS_WARNING("ClusterIterator has already reached the end");
         return;
     }
 
--- a/intl/unicharutil/util/nsUnicodeProperties.h
+++ b/intl/unicharutil/util/nsUnicodeProperties.h
@@ -5,30 +5,30 @@
 
 #ifndef NS_UNICODEPROPERTIES_H
 #define NS_UNICODEPROPERTIES_H
 
 #include "nsBidiUtils.h"
 #include "nsIUGenCategory.h"
 #include "nsUnicodeScriptCodes.h"
 
-const nsCharProps1& GetCharProps1(uint32_t aCh);
 const nsCharProps2& GetCharProps2(uint32_t aCh);
 
 namespace mozilla {
 
 namespace unicode {
 
 extern nsIUGenCategory::nsUGenCategory sDetailedToGeneralCategory[];
 
+// Return whether the char has a mirrored-pair counterpart.
 uint32_t GetMirroredChar(uint32_t aCh);
 
-inline uint8_t GetCombiningClass(uint32_t aCh) {
-  return GetCharProps1(aCh).mCombiningClass;
-}
+bool HasMirroredChar(uint32_t aChr);
+
+uint8_t GetCombiningClass(uint32_t aCh);
 
 // returns the detailed General Category in terms of HB_UNICODE_* values
 inline uint8_t GetGeneralCategory(uint32_t aCh) {
   return GetCharProps2(aCh).mCategory;
 }
 
 // returns the simplified Gen Category as defined in nsIUGenCategory
 inline nsIUGenCategory::nsUGenCategory GetGenCategory(uint32_t aCh) {
@@ -99,29 +99,16 @@ HanVariantType GetHanVariant(uint32_t aC
 uint32_t GetFullWidth(uint32_t aCh);
 
 bool IsClusterExtender(uint32_t aCh, uint8_t aCategory);
 
 inline bool IsClusterExtender(uint32_t aCh) {
   return IsClusterExtender(aCh, GetGeneralCategory(aCh));
 }
 
-enum HSType {
-  HST_NONE = 0x00,
-  HST_L    = 0x01,
-  HST_V    = 0x02,
-  HST_T    = 0x04,
-  HST_LV   = 0x03,
-  HST_LVT  = 0x07
-};
-
-inline HSType GetHangulSyllableType(uint32_t aCh) {
-  return HSType(GetCharProps1(aCh).mHangulType);
-}
-
 // Case mappings for the full Unicode range;
 // note that it may be worth testing for ASCII chars and taking
 // a separate fast-path before calling these, in perf-critical places
 uint32_t GetUppercase(uint32_t aCh);
 uint32_t GetLowercase(uint32_t aCh);
 uint32_t GetTitlecaseForLower(uint32_t aCh); // maps LC to titlecase, UC unchanged
 uint32_t GetTitlecaseForAll(uint32_t aCh); // maps both UC and LC to titlecase