[cfe-commits] r162407 - in /cfe/trunk: lib/AST/CommentLexer.cpp test/Sema/warn-documentation.cpp unittests/AST/CommentLexer.cpp

Douglas Gregor dgregor at apple.com
Sun Aug 26 09:06:04 PDT 2012


On Aug 25, 2012, at 1:23 PM, Dmitri Gribenko <gribozavr at gmail.com> wrote:

> On Fri, Aug 24, 2012 at 6:33 PM, Jordan Rose <jordan_rose at apple.com> wrote:
>> On Aug 22, 2012, at 15:56 , Dmitri Gribenko <gribozavr at gmail.com> wrote:
>>> +bool isHTMLTagName(StringRef Name) {
>>> +  return llvm::StringSwitch<bool>(Name)
>>> +      .Cases("em", "strong", true)
>>> +      .Cases("tt", "i", "b", "big", "small", true)
>>> +      .Cases("strike", "s", "u", "font", true)
>>> +      .Case("a", true)
>>> +      .Case("hr", true)
>>> +      .Cases("div", "span", true)
>>> +      .Cases("h1", "h2", "h3", true)
>>> +      .Cases("h4", "h5", "h6", true)
>>> +      .Case("code", true)
>>> +      .Case("blockquote", true)
>>> +      .Cases("sub", "sup", true)
>>> +      .Case("img", true)
>>> +      .Case("p", true)
>>> +      .Case("br", true)
>>> +      .Case("pre", true)
>>> +      .Cases("ins", "del", true)
>>> +      .Cases("ul", "ol", "li", true)
>>> +      .Cases("dl", "dt", "dd", true)
>>> +      .Cases("table", "caption", true)
>>> +      .Cases("thead", "tfoot", "tbody", true)
>>> +      .Cases("colgroup", "col", true)
>>> +      .Cases("tr", "th", "td", true)
>>> +      .Default(false);
>>> +}
>> 
>> This is going to be very slow (StringSwitch just chains the string comparisons). Maybe we should use a StringMap instead?
> 
> It is a good idea, but it would require some refactoring since
> StringMap should be populated at runtime and we want to do that only
> once.

tblgen can build fast matchers for a fixed set of strings. 

> Dmitri
> 
> -- 
> main(i,j){for(i=2;;i++){for(j=2;j<i;j++){if(!(i%j)){j=0;break;}}if
> (j){printf("%d\n",i);}}} /*Dmitri Gribenko <gribozavr at gmail.com>*/
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits



More information about the cfe-commits mailing list