@@ -45,7 +45,7 @@ static constexpr Match NotMatched = {"", 0};
4545class RegexMatcher {
4646public:
4747 Error insert (StringRef Pattern, unsigned LineNumber);
48- void preprocess (bool BySize );
48+ void preprocess ();
4949
5050 Match match (StringRef Query) const ;
5151
@@ -63,7 +63,7 @@ class RegexMatcher {
6363class GlobMatcher {
6464public:
6565 Error insert (StringRef Pattern, unsigned LineNumber);
66- void preprocess (bool BySize );
66+ void preprocess ();
6767
6868 Match match (StringRef Query) const ;
6969
@@ -92,7 +92,7 @@ class Matcher {
9292 Matcher (bool UseGlobs, bool RemoveDotSlash);
9393
9494 Error insert (StringRef Pattern, unsigned LineNumber);
95- void preprocess (bool BySize );
95+ void preprocess ();
9696 Match match (StringRef Query) const ;
9797
9898 bool matchAny (StringRef Query) const { return match (Query).second > 0 ; }
@@ -125,13 +125,7 @@ Error RegexMatcher::insert(StringRef Pattern, unsigned LineNumber) {
125125 return Error::success ();
126126}
127127
128- void RegexMatcher::preprocess (bool BySize) {
129- if (BySize) {
130- llvm::stable_sort (RegExes, [](const Reg &A, const Reg &B) {
131- return A.Name .size () < B.Name .size ();
132- });
133- }
134- }
128+ void RegexMatcher::preprocess () {}
135129
136130Match RegexMatcher::match (StringRef Query) const {
137131 for (const auto &R : reverse (RegExes))
@@ -151,13 +145,7 @@ Error GlobMatcher::insert(StringRef Pattern, unsigned LineNumber) {
151145 return Error::success ();
152146}
153147
154- void GlobMatcher::preprocess (bool BySize) {
155- if (BySize) {
156- llvm::stable_sort (Globs, [](const Glob &A, const Glob &B) {
157- return A.Name .size () < B.Name .size ();
158- });
159- }
160-
148+ void GlobMatcher::preprocess () {
161149 for (const auto &[Idx, G] : enumerate(Globs)) {
162150 StringRef Prefix = G.Pattern .prefix ();
163151 StringRef Suffix = G.Pattern .suffix ();
@@ -241,8 +229,8 @@ Error Matcher::insert(StringRef Pattern, unsigned LineNumber) {
241229 return std::visit ([&](auto &V) { return V.insert (Pattern, LineNumber); }, M);
242230}
243231
244- void Matcher::preprocess (bool BySize ) {
245- return std::visit ([&](auto &V) { return V.preprocess (BySize ); }, M);
232+ void Matcher::preprocess () {
233+ return std::visit ([&](auto &V) { return V.preprocess (); }, M);
246234}
247235
248236Match Matcher::match (StringRef Query) const {
@@ -254,7 +242,7 @@ Match Matcher::match(StringRef Query) const {
254242
255243class SpecialCaseList ::Section::SectionImpl {
256244 friend class SpecialCaseList ;
257- void preprocess (bool OrderBySize );
245+ void preprocess ();
258246 const Matcher *findMatcher (StringRef Prefix, StringRef Category) const ;
259247
260248public:
@@ -315,17 +303,17 @@ bool SpecialCaseList::createInternal(const std::vector<std::string> &Paths,
315303 return false ;
316304 }
317305 std::string ParseError;
318- if (!parse (i, FileOrErr.get ().get (), ParseError, /* OrderBySize= */ false )) {
306+ if (!parse (i, FileOrErr.get ().get (), ParseError)) {
319307 Error = (Twine (" error parsing file '" ) + Path + " ': " + ParseError).str ();
320308 return false ;
321309 }
322310 }
323311 return true ;
324312}
325313
326- bool SpecialCaseList::createInternal (const MemoryBuffer *MB, std::string &Error,
327- bool OrderBySize ) {
328- if (!parse (0 , MB, Error, OrderBySize ))
314+ bool SpecialCaseList::createInternal (const MemoryBuffer *MB,
315+ std::string &Error ) {
316+ if (!parse (0 , MB, Error))
329317 return false ;
330318 return true ;
331319}
@@ -352,7 +340,7 @@ SpecialCaseList::addSection(StringRef SectionStr, unsigned FileNo,
352340}
353341
354342bool SpecialCaseList::parse (unsigned FileIdx, const MemoryBuffer *MB,
355- std::string &Error, bool OrderBySize ) {
343+ std::string &Error) {
356344 unsigned long long Version = 2 ;
357345
358346 StringRef Header = MB->getBuffer ();
@@ -428,7 +416,7 @@ bool SpecialCaseList::parse(unsigned FileIdx, const MemoryBuffer *MB,
428416 }
429417
430418 for (Section &S : Sections)
431- S.Impl ->preprocess (OrderBySize );
419+ S.Impl ->preprocess ();
432420
433421 return true ;
434422}
@@ -479,11 +467,11 @@ SpecialCaseList::Section::SectionImpl::findMatcher(StringRef Prefix,
479467 return &II->second ;
480468}
481469
482- void SpecialCaseList::Section::SectionImpl::preprocess (bool OrderBySize ) {
483- SectionMatcher.preprocess (false );
470+ void SpecialCaseList::Section::SectionImpl::preprocess () {
471+ SectionMatcher.preprocess ();
484472 for (auto &[K1, E] : Entries)
485473 for (auto &[K2, M] : E)
486- M.preprocess (OrderBySize );
474+ M.preprocess ();
487475}
488476
489477unsigned SpecialCaseList::Section::getLastMatch (StringRef Prefix,
@@ -494,14 +482,6 @@ unsigned SpecialCaseList::Section::getLastMatch(StringRef Prefix,
494482 return 0 ;
495483}
496484
497- StringRef SpecialCaseList::Section::getLongestMatch (StringRef Prefix,
498- StringRef Query,
499- StringRef Category) const {
500- if (const Matcher *M = Impl->findMatcher (Prefix, Category))
501- return M->match (Query).first ;
502- return {};
503- }
504-
505485bool SpecialCaseList::Section::hasPrefix (StringRef Prefix) const {
506486 return Impl->Entries .find (Prefix) != Impl->Entries .end ();
507487}
0 commit comments