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

Dmitri Gribenko gribozavr at gmail.com
Thu Aug 30 19:26:41 PDT 2012


On Sun, Aug 26, 2012 at 7:06 PM, Douglas Gregor <dgregor at apple.com> wrote:
>
> 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.

Refactored in r162969.

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>*/



More information about the cfe-commits mailing list