optimize parsing of templates like p{IsArabic}, etc

use qBinaryFind() with a case-sensitive string comparison
instead of QHash. This also improves startup time and reduces
runtime memory consumption.

Change-Id: I5c5f7cae5e42acb3fa727acac19fe39c53310329
Reviewed-on: http://codereview.qt.nokia.com/3673
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
This commit is contained in:
Ritt Konstantin 2011-07-15 06:00:05 +04:00 committed by Qt by Nokia
parent 24667a905d
commit 580bd22dc6

View File

@ -1252,10 +1252,6 @@ private:
friend class Box; friend class Box;
#ifndef QT_NO_REGEXP_CCLASS
void setupCategoriesRangeMap();
#endif
/* /*
This is the lexical analyzer for regular expressions. This is the lexical analyzer for regular expressions.
*/ */
@ -1295,9 +1291,6 @@ private:
int yyTok; // the last token read int yyTok; // the last token read
bool yyMayCapture; // set this to false to disable capturing bool yyMayCapture; // set this to false to disable capturing
#ifndef QT_NO_REGEXP_CCLASS
QHash<QByteArray, QPair<int, int> > categoriesRangeMap; // fast lookup hash for xml schema extensions
#endif
friend struct QRegExpMatchState; friend struct QRegExpMatchState;
}; };
@ -2740,152 +2733,161 @@ void QRegExpEngine::Box::addAnchorsToEngine(const Box &to) const
} }
#ifndef QT_NO_REGEXP_CCLASS #ifndef QT_NO_REGEXP_CCLASS
void QRegExpEngine::setupCategoriesRangeMap() // fast lookup hash for xml schema extensions
{ // sorted by name for b-search
categoriesRangeMap.insert("IsBasicLatin", qMakePair(0x0000, 0x007F)); static const struct CategoriesRangeMapEntry {
categoriesRangeMap.insert("IsLatin-1Supplement", qMakePair(0x0080, 0x00FF)); const char name[40];
categoriesRangeMap.insert("IsLatinExtended-A", qMakePair(0x0100, 0x017F)); uint first, second;
categoriesRangeMap.insert("IsLatinExtended-B", qMakePair(0x0180, 0x024F)); } categoriesRangeMap[] = {
categoriesRangeMap.insert("IsIPAExtensions", qMakePair(0x0250, 0x02AF)); { "AegeanNumbers", 0x10100, 0x1013F },
categoriesRangeMap.insert("IsSpacingModifierLetters", qMakePair(0x02B0, 0x02FF)); { "AlphabeticPresentationForms", 0xFB00, 0xFB4F },
categoriesRangeMap.insert("IsCombiningDiacriticalMarks", qMakePair(0x0300, 0x036F)); { "AncientGreekMusicalNotation", 0x1D200, 0x1D24F },
categoriesRangeMap.insert("IsGreek", qMakePair(0x0370, 0x03FF)); { "AncientGreekNumbers", 0x10140, 0x1018F },
categoriesRangeMap.insert("IsCyrillic", qMakePair(0x0400, 0x04FF)); { "Arabic", 0x0600, 0x06FF },
categoriesRangeMap.insert("IsCyrillicSupplement", qMakePair(0x0500, 0x052F)); { "ArabicPresentationForms-A", 0xFB50, 0xFDFF },
categoriesRangeMap.insert("IsArmenian", qMakePair(0x0530, 0x058F)); { "ArabicPresentationForms-B", 0xFE70, 0xFEFF },
categoriesRangeMap.insert("IsHebrew", qMakePair(0x0590, 0x05FF)); { "ArabicSupplement", 0x0750, 0x077F },
categoriesRangeMap.insert("IsArabic", qMakePair(0x0600, 0x06FF)); { "Armenian", 0x0530, 0x058F },
categoriesRangeMap.insert("IsSyriac", qMakePair(0x0700, 0x074F)); { "Arrows", 0x2190, 0x21FF },
categoriesRangeMap.insert("IsArabicSupplement", qMakePair(0x0750, 0x077F)); { "BasicLatin", 0x0000, 0x007F },
categoriesRangeMap.insert("IsThaana", qMakePair(0x0780, 0x07BF)); { "Bengali", 0x0980, 0x09FF },
categoriesRangeMap.insert("IsDevanagari", qMakePair(0x0900, 0x097F)); { "BlockElements", 0x2580, 0x259F },
categoriesRangeMap.insert("IsBengali", qMakePair(0x0980, 0x09FF)); { "Bopomofo", 0x3100, 0x312F },
categoriesRangeMap.insert("IsGurmukhi", qMakePair(0x0A00, 0x0A7F)); { "BopomofoExtended", 0x31A0, 0x31BF },
categoriesRangeMap.insert("IsGujarati", qMakePair(0x0A80, 0x0AFF)); { "BoxDrawing", 0x2500, 0x257F },
categoriesRangeMap.insert("IsOriya", qMakePair(0x0B00, 0x0B7F)); { "BraillePatterns", 0x2800, 0x28FF },
categoriesRangeMap.insert("IsTamil", qMakePair(0x0B80, 0x0BFF)); { "Buginese", 0x1A00, 0x1A1F },
categoriesRangeMap.insert("IsTelugu", qMakePair(0x0C00, 0x0C7F)); { "Buhid", 0x1740, 0x175F },
categoriesRangeMap.insert("IsKannada", qMakePair(0x0C80, 0x0CFF)); { "ByzantineMusicalSymbols", 0x1D000, 0x1D0FF },
categoriesRangeMap.insert("IsMalayalam", qMakePair(0x0D00, 0x0D7F)); { "CJKCompatibility", 0x3300, 0x33FF },
categoriesRangeMap.insert("IsSinhala", qMakePair(0x0D80, 0x0DFF)); { "CJKCompatibilityForms", 0xFE30, 0xFE4F },
categoriesRangeMap.insert("IsThai", qMakePair(0x0E00, 0x0E7F)); { "CJKCompatibilityIdeographs", 0xF900, 0xFAFF },
categoriesRangeMap.insert("IsLao", qMakePair(0x0E80, 0x0EFF)); { "CJKCompatibilityIdeographsSupplement", 0x2F800, 0x2FA1F },
categoriesRangeMap.insert("IsTibetan", qMakePair(0x0F00, 0x0FFF)); { "CJKRadicalsSupplement", 0x2E80, 0x2EFF },
categoriesRangeMap.insert("IsMyanmar", qMakePair(0x1000, 0x109F)); { "CJKStrokes", 0x31C0, 0x31EF },
categoriesRangeMap.insert("IsGeorgian", qMakePair(0x10A0, 0x10FF)); { "CJKSymbolsandPunctuation", 0x3000, 0x303F },
categoriesRangeMap.insert("IsHangulJamo", qMakePair(0x1100, 0x11FF)); { "CJKUnifiedIdeographs", 0x4E00, 0x9FFF },
categoriesRangeMap.insert("IsEthiopic", qMakePair(0x1200, 0x137F)); { "CJKUnifiedIdeographsExtensionA", 0x3400, 0x4DB5 },
categoriesRangeMap.insert("IsEthiopicSupplement", qMakePair(0x1380, 0x139F)); { "CJKUnifiedIdeographsExtensionB", 0x20000, 0x2A6DF },
categoriesRangeMap.insert("IsCherokee", qMakePair(0x13A0, 0x13FF)); { "Cherokee", 0x13A0, 0x13FF },
categoriesRangeMap.insert("IsUnifiedCanadianAboriginalSyllabics", qMakePair(0x1400, 0x167F)); { "CombiningDiacriticalMarks", 0x0300, 0x036F },
categoriesRangeMap.insert("IsOgham", qMakePair(0x1680, 0x169F)); { "CombiningDiacriticalMarksSupplement", 0x1DC0, 0x1DFF },
categoriesRangeMap.insert("IsRunic", qMakePair(0x16A0, 0x16FF)); { "CombiningHalfMarks", 0xFE20, 0xFE2F },
categoriesRangeMap.insert("IsTagalog", qMakePair(0x1700, 0x171F)); { "CombiningMarksforSymbols", 0x20D0, 0x20FF },
categoriesRangeMap.insert("IsHanunoo", qMakePair(0x1720, 0x173F)); { "ControlPictures", 0x2400, 0x243F },
categoriesRangeMap.insert("IsBuhid", qMakePair(0x1740, 0x175F)); { "Coptic", 0x2C80, 0x2CFF },
categoriesRangeMap.insert("IsTagbanwa", qMakePair(0x1760, 0x177F)); { "CurrencySymbols", 0x20A0, 0x20CF },
categoriesRangeMap.insert("IsKhmer", qMakePair(0x1780, 0x17FF)); { "CypriotSyllabary", 0x10800, 0x1083F },
categoriesRangeMap.insert("IsMongolian", qMakePair(0x1800, 0x18AF)); { "Cyrillic", 0x0400, 0x04FF },
categoriesRangeMap.insert("IsLimbu", qMakePair(0x1900, 0x194F)); { "CyrillicSupplement", 0x0500, 0x052F },
categoriesRangeMap.insert("IsTaiLe", qMakePair(0x1950, 0x197F)); { "Deseret", 0x10400, 0x1044F },
categoriesRangeMap.insert("IsNewTaiLue", qMakePair(0x1980, 0x19DF)); { "Devanagari", 0x0900, 0x097F },
categoriesRangeMap.insert("IsKhmerSymbols", qMakePair(0x19E0, 0x19FF)); { "Dingbats", 0x2700, 0x27BF },
categoriesRangeMap.insert("IsBuginese", qMakePair(0x1A00, 0x1A1F)); { "EnclosedAlphanumerics", 0x2460, 0x24FF },
categoriesRangeMap.insert("IsPhoneticExtensions", qMakePair(0x1D00, 0x1D7F)); { "EnclosedCJKLettersandMonths", 0x3200, 0x32FF },
categoriesRangeMap.insert("IsPhoneticExtensionsSupplement", qMakePair(0x1D80, 0x1DBF)); { "Ethiopic", 0x1200, 0x137F },
categoriesRangeMap.insert("IsCombiningDiacriticalMarksSupplement", qMakePair(0x1DC0, 0x1DFF)); { "EthiopicExtended", 0x2D80, 0x2DDF },
categoriesRangeMap.insert("IsLatinExtendedAdditional", qMakePair(0x1E00, 0x1EFF)); { "EthiopicSupplement", 0x1380, 0x139F },
categoriesRangeMap.insert("IsGreekExtended", qMakePair(0x1F00, 0x1FFF)); { "GeneralPunctuation", 0x2000, 0x206F },
categoriesRangeMap.insert("IsGeneralPunctuation", qMakePair(0x2000, 0x206F)); { "GeometricShapes", 0x25A0, 0x25FF },
categoriesRangeMap.insert("IsSuperscriptsandSubscripts", qMakePair(0x2070, 0x209F)); { "Georgian", 0x10A0, 0x10FF },
categoriesRangeMap.insert("IsCurrencySymbols", qMakePair(0x20A0, 0x20CF)); { "GeorgianSupplement", 0x2D00, 0x2D2F },
categoriesRangeMap.insert("IsCombiningMarksforSymbols", qMakePair(0x20D0, 0x20FF)); { "Glagolitic", 0x2C00, 0x2C5F },
categoriesRangeMap.insert("IsLetterlikeSymbols", qMakePair(0x2100, 0x214F)); { "Gothic", 0x10330, 0x1034F },
categoriesRangeMap.insert("IsNumberForms", qMakePair(0x2150, 0x218F)); { "Greek", 0x0370, 0x03FF },
categoriesRangeMap.insert("IsArrows", qMakePair(0x2190, 0x21FF)); { "GreekExtended", 0x1F00, 0x1FFF },
categoriesRangeMap.insert("IsMathematicalOperators", qMakePair(0x2200, 0x22FF)); { "Gujarati", 0x0A80, 0x0AFF },
categoriesRangeMap.insert("IsMiscellaneousTechnical", qMakePair(0x2300, 0x23FF)); { "Gurmukhi", 0x0A00, 0x0A7F },
categoriesRangeMap.insert("IsControlPictures", qMakePair(0x2400, 0x243F)); { "HalfwidthandFullwidthForms", 0xFF00, 0xFFEF },
categoriesRangeMap.insert("IsOpticalCharacterRecognition", qMakePair(0x2440, 0x245F)); { "HangulCompatibilityJamo", 0x3130, 0x318F },
categoriesRangeMap.insert("IsEnclosedAlphanumerics", qMakePair(0x2460, 0x24FF)); { "HangulJamo", 0x1100, 0x11FF },
categoriesRangeMap.insert("IsBoxDrawing", qMakePair(0x2500, 0x257F)); { "HangulSyllables", 0xAC00, 0xD7A3 },
categoriesRangeMap.insert("IsBlockElements", qMakePair(0x2580, 0x259F)); { "Hanunoo", 0x1720, 0x173F },
categoriesRangeMap.insert("IsGeometricShapes", qMakePair(0x25A0, 0x25FF)); { "Hebrew", 0x0590, 0x05FF },
categoriesRangeMap.insert("IsMiscellaneousSymbols", qMakePair(0x2600, 0x26FF)); { "Hiragana", 0x3040, 0x309F },
categoriesRangeMap.insert("IsDingbats", qMakePair(0x2700, 0x27BF)); { "IPAExtensions", 0x0250, 0x02AF },
categoriesRangeMap.insert("IsMiscellaneousMathematicalSymbols-A", qMakePair(0x27C0, 0x27EF)); { "IdeographicDescriptionCharacters", 0x2FF0, 0x2FFF },
categoriesRangeMap.insert("IsSupplementalArrows-A", qMakePair(0x27F0, 0x27FF)); { "Kanbun", 0x3190, 0x319F },
categoriesRangeMap.insert("IsBraillePatterns", qMakePair(0x2800, 0x28FF)); { "KangxiRadicals", 0x2F00, 0x2FDF },
categoriesRangeMap.insert("IsSupplementalArrows-B", qMakePair(0x2900, 0x297F)); { "Kannada", 0x0C80, 0x0CFF },
categoriesRangeMap.insert("IsMiscellaneousMathematicalSymbols-B", qMakePair(0x2980, 0x29FF)); { "Katakana", 0x30A0, 0x30FF },
categoriesRangeMap.insert("IsSupplementalMathematicalOperators", qMakePair(0x2A00, 0x2AFF)); { "KatakanaPhoneticExtensions", 0x31F0, 0x31FF },
categoriesRangeMap.insert("IsMiscellaneousSymbolsandArrows", qMakePair(0x2B00, 0x2BFF)); { "Kharoshthi", 0x10A00, 0x10A5F },
categoriesRangeMap.insert("IsGlagolitic", qMakePair(0x2C00, 0x2C5F)); { "Khmer", 0x1780, 0x17FF },
categoriesRangeMap.insert("IsCoptic", qMakePair(0x2C80, 0x2CFF)); { "KhmerSymbols", 0x19E0, 0x19FF },
categoriesRangeMap.insert("IsGeorgianSupplement", qMakePair(0x2D00, 0x2D2F)); { "Lao", 0x0E80, 0x0EFF },
categoriesRangeMap.insert("IsTifinagh", qMakePair(0x2D30, 0x2D7F)); { "Latin-1Supplement", 0x0080, 0x00FF },
categoriesRangeMap.insert("IsEthiopicExtended", qMakePair(0x2D80, 0x2DDF)); { "LatinExtended-A", 0x0100, 0x017F },
categoriesRangeMap.insert("IsSupplementalPunctuation", qMakePair(0x2E00, 0x2E7F)); { "LatinExtended-B", 0x0180, 0x024F },
categoriesRangeMap.insert("IsCJKRadicalsSupplement", qMakePair(0x2E80, 0x2EFF)); { "LatinExtendedAdditional", 0x1E00, 0x1EFF },
categoriesRangeMap.insert("IsKangxiRadicals", qMakePair(0x2F00, 0x2FDF)); { "LetterlikeSymbols", 0x2100, 0x214F },
categoriesRangeMap.insert("IsIdeographicDescriptionCharacters", qMakePair(0x2FF0, 0x2FFF)); { "Limbu", 0x1900, 0x194F },
categoriesRangeMap.insert("IsCJKSymbolsandPunctuation", qMakePair(0x3000, 0x303F)); { "LinearBIdeograms", 0x10080, 0x100FF },
categoriesRangeMap.insert("IsHiragana", qMakePair(0x3040, 0x309F)); { "LinearBSyllabary", 0x10000, 0x1007F },
categoriesRangeMap.insert("IsKatakana", qMakePair(0x30A0, 0x30FF)); { "Malayalam", 0x0D00, 0x0D7F },
categoriesRangeMap.insert("IsBopomofo", qMakePair(0x3100, 0x312F)); { "MathematicalAlphanumericSymbols", 0x1D400, 0x1D7FF },
categoriesRangeMap.insert("IsHangulCompatibilityJamo", qMakePair(0x3130, 0x318F)); { "MathematicalOperators", 0x2200, 0x22FF },
categoriesRangeMap.insert("IsKanbun", qMakePair(0x3190, 0x319F)); { "MiscellaneousMathematicalSymbols-A", 0x27C0, 0x27EF },
categoriesRangeMap.insert("IsBopomofoExtended", qMakePair(0x31A0, 0x31BF)); { "MiscellaneousMathematicalSymbols-B", 0x2980, 0x29FF },
categoriesRangeMap.insert("IsCJKStrokes", qMakePair(0x31C0, 0x31EF)); { "MiscellaneousSymbols", 0x2600, 0x26FF },
categoriesRangeMap.insert("IsKatakanaPhoneticExtensions", qMakePair(0x31F0, 0x31FF)); { "MiscellaneousSymbolsandArrows", 0x2B00, 0x2BFF },
categoriesRangeMap.insert("IsEnclosedCJKLettersandMonths", qMakePair(0x3200, 0x32FF)); { "MiscellaneousTechnical", 0x2300, 0x23FF },
categoriesRangeMap.insert("IsCJKCompatibility", qMakePair(0x3300, 0x33FF)); { "ModifierToneLetters", 0xA700, 0xA71F },
categoriesRangeMap.insert("IsCJKUnifiedIdeographsExtensionA", qMakePair(0x3400, 0x4DB5)); { "Mongolian", 0x1800, 0x18AF },
categoriesRangeMap.insert("IsYijingHexagramSymbols", qMakePair(0x4DC0, 0x4DFF)); { "MusicalSymbols", 0x1D100, 0x1D1FF },
categoriesRangeMap.insert("IsCJKUnifiedIdeographs", qMakePair(0x4E00, 0x9FFF)); { "Myanmar", 0x1000, 0x109F },
categoriesRangeMap.insert("IsYiSyllables", qMakePair(0xA000, 0xA48F)); { "NewTaiLue", 0x1980, 0x19DF },
categoriesRangeMap.insert("IsYiRadicals", qMakePair(0xA490, 0xA4CF)); { "NumberForms", 0x2150, 0x218F },
categoriesRangeMap.insert("IsModifierToneLetters", qMakePair(0xA700, 0xA71F)); { "Ogham", 0x1680, 0x169F },
categoriesRangeMap.insert("IsSylotiNagri", qMakePair(0xA800, 0xA82F)); { "OldItalic", 0x10300, 0x1032F },
categoriesRangeMap.insert("IsHangulSyllables", qMakePair(0xAC00, 0xD7A3)); { "OldPersian", 0x103A0, 0x103DF },
categoriesRangeMap.insert("IsPrivateUse", qMakePair(0xE000, 0xF8FF)); { "OpticalCharacterRecognition", 0x2440, 0x245F },
categoriesRangeMap.insert("IsCJKCompatibilityIdeographs", qMakePair(0xF900, 0xFAFF)); { "Oriya", 0x0B00, 0x0B7F },
categoriesRangeMap.insert("IsAlphabeticPresentationForms", qMakePair(0xFB00, 0xFB4F)); { "Osmanya", 0x10480, 0x104AF },
categoriesRangeMap.insert("IsArabicPresentationForms-A", qMakePair(0xFB50, 0xFDFF)); { "PhoneticExtensions", 0x1D00, 0x1D7F },
categoriesRangeMap.insert("IsVariationSelectors", qMakePair(0xFE00, 0xFE0F)); { "PhoneticExtensionsSupplement", 0x1D80, 0x1DBF },
categoriesRangeMap.insert("IsVerticalForms", qMakePair(0xFE10, 0xFE1F)); { "PrivateUse", 0xE000, 0xF8FF },
categoriesRangeMap.insert("IsCombiningHalfMarks", qMakePair(0xFE20, 0xFE2F)); { "Runic", 0x16A0, 0x16FF },
categoriesRangeMap.insert("IsCJKCompatibilityForms", qMakePair(0xFE30, 0xFE4F)); { "Shavian", 0x10450, 0x1047F },
categoriesRangeMap.insert("IsSmallFormVariants", qMakePair(0xFE50, 0xFE6F)); { "Sinhala", 0x0D80, 0x0DFF },
categoriesRangeMap.insert("IsArabicPresentationForms-B", qMakePair(0xFE70, 0xFEFF)); { "SmallFormVariants", 0xFE50, 0xFE6F },
categoriesRangeMap.insert("IsHalfwidthandFullwidthForms", qMakePair(0xFF00, 0xFFEF)); { "SpacingModifierLetters", 0x02B0, 0x02FF },
categoriesRangeMap.insert("IsSpecials", qMakePair(0xFFF0, 0xFFFF)); { "Specials", 0xFFF0, 0xFFFF },
categoriesRangeMap.insert("IsLinearBSyllabary", qMakePair(0x10000, 0x1007F)); { "SuperscriptsandSubscripts", 0x2070, 0x209F },
categoriesRangeMap.insert("IsLinearBIdeograms", qMakePair(0x10080, 0x100FF)); { "SupplementalArrows-A", 0x27F0, 0x27FF },
categoriesRangeMap.insert("IsAegeanNumbers", qMakePair(0x10100, 0x1013F)); { "SupplementalArrows-B", 0x2900, 0x297F },
categoriesRangeMap.insert("IsAncientGreekNumbers", qMakePair(0x10140, 0x1018F)); { "SupplementalMathematicalOperators", 0x2A00, 0x2AFF },
categoriesRangeMap.insert("IsOldItalic", qMakePair(0x10300, 0x1032F)); { "SupplementalPunctuation", 0x2E00, 0x2E7F },
categoriesRangeMap.insert("IsGothic", qMakePair(0x10330, 0x1034F)); { "SupplementaryPrivateUseArea-A", 0xF0000, 0xFFFFF },
categoriesRangeMap.insert("IsUgaritic", qMakePair(0x10380, 0x1039F)); { "SupplementaryPrivateUseArea-B", 0x100000, 0x10FFFF },
categoriesRangeMap.insert("IsOldPersian", qMakePair(0x103A0, 0x103DF)); { "SylotiNagri", 0xA800, 0xA82F },
categoriesRangeMap.insert("IsDeseret", qMakePair(0x10400, 0x1044F)); { "Syriac", 0x0700, 0x074F },
categoriesRangeMap.insert("IsShavian", qMakePair(0x10450, 0x1047F)); { "Tagalog", 0x1700, 0x171F },
categoriesRangeMap.insert("IsOsmanya", qMakePair(0x10480, 0x104AF)); { "Tagbanwa", 0x1760, 0x177F },
categoriesRangeMap.insert("IsCypriotSyllabary", qMakePair(0x10800, 0x1083F)); { "Tags", 0xE0000, 0xE007F },
categoriesRangeMap.insert("IsKharoshthi", qMakePair(0x10A00, 0x10A5F)); { "TaiLe", 0x1950, 0x197F },
categoriesRangeMap.insert("IsByzantineMusicalSymbols", qMakePair(0x1D000, 0x1D0FF)); { "TaiXuanJingSymbols", 0x1D300, 0x1D35F },
categoriesRangeMap.insert("IsMusicalSymbols", qMakePair(0x1D100, 0x1D1FF)); { "Tamil", 0x0B80, 0x0BFF },
categoriesRangeMap.insert("IsAncientGreekMusicalNotation", qMakePair(0x1D200, 0x1D24F)); { "Telugu", 0x0C00, 0x0C7F },
categoriesRangeMap.insert("IsTaiXuanJingSymbols", qMakePair(0x1D300, 0x1D35F)); { "Thaana", 0x0780, 0x07BF },
categoriesRangeMap.insert("IsMathematicalAlphanumericSymbols", qMakePair(0x1D400, 0x1D7FF)); { "Thai", 0x0E00, 0x0E7F },
categoriesRangeMap.insert("IsCJKUnifiedIdeographsExtensionB", qMakePair(0x20000, 0x2A6DF)); { "Tibetan", 0x0F00, 0x0FFF },
categoriesRangeMap.insert("IsCJKCompatibilityIdeographsSupplement", qMakePair(0x2F800, 0x2FA1F)); { "Tifinagh", 0x2D30, 0x2D7F },
categoriesRangeMap.insert("IsTags", qMakePair(0xE0000, 0xE007F)); { "Ugaritic", 0x10380, 0x1039F },
categoriesRangeMap.insert("IsVariationSelectorsSupplement", qMakePair(0xE0100, 0xE01EF)); { "UnifiedCanadianAboriginalSyllabics", 0x1400, 0x167F },
categoriesRangeMap.insert("IsSupplementaryPrivateUseArea-A", qMakePair(0xF0000, 0xFFFFF)); { "VariationSelectors", 0xFE00, 0xFE0F },
categoriesRangeMap.insert("IsSupplementaryPrivateUseArea-B", qMakePair(0x100000, 0x10FFFF)); { "VariationSelectorsSupplement", 0xE0100, 0xE01EF },
} { "VerticalForms", 0xFE10, 0xFE1F },
#endif { "YiRadicals", 0xA490, 0xA4CF },
{ "YiSyllables", 0xA000, 0xA48F },
{ "YijingHexagramSymbols", 0x4DC0, 0x4DFF }
};
inline bool operator<(const char *name, const CategoriesRangeMapEntry &entry)
{ return qstrcmp(name, entry.name) < 0; }
inline bool operator<(const CategoriesRangeMapEntry &entry, const char *name)
{ return qstrcmp(entry.name, name) < 0; }
#endif // QT_NO_REGEXP_CCLASS
int QRegExpEngine::getChar() int QRegExpEngine::getChar()
{ {
@ -3231,15 +3233,12 @@ int QRegExpEngine::getEscape()
break; break;
} }
} else if (catlen > 2 && category.at(0) == 'I' && category.at(1) == 's') { } else if (catlen > 2 && category.at(0) == 'I' && category.at(1) == 's') {
if (categoriesRangeMap.isEmpty()) static const int N = sizeof(categoriesRangeMap) / sizeof(categoriesRangeMap[0]);
setupCategoriesRangeMap(); const CategoriesRangeMapEntry *r = qBinaryFind(categoriesRangeMap, categoriesRangeMap + N, category.constData() + 2);
if (r != categoriesRangeMap + N)
if (categoriesRangeMap.contains(category)) { yyCharClass->addRange(r->first, r->second);
const QPair<int, int> range = categoriesRangeMap.value(category); else
yyCharClass->addRange(range.first, range.second);
} else {
error(RXERR_CATEGORY); error(RXERR_CATEGORY);
}
} else { } else {
error(RXERR_CATEGORY); error(RXERR_CATEGORY);
} }