[llvm-dev] StringSwitch efficiency
Chris Lattner via llvm-dev
llvm-dev at lists.llvm.org
Thu Oct 29 11:28:43 PDT 2020
Yeah, years ago, the compiler did the right thing through a combination of jump threading and simple redundancy elimination. StringSwitch does a first character specialization IIRC.
-Chris
> On Oct 28, 2020, at 9:01 PM, Stephen Checkoway via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>
>
>
>> On Oct 28, 2020, at 14:09, Paul C. Anagnostopoulos via llvm-dev <llvm-dev at lists.llvm.org> wrote:
>>
>> StringSwitch just uses a series of Case functions that compare the target against each case string. Once the target is matched, the remaining Case functions bypass the comparison. One way or the other, it goes through all the Case's. I don't think there is any way to optimize this. Does anyone know if the compiler does something clever?
>
> Hi Paul,
>
> This has come up on the list before [1]. The suggestion at the end of that thread was to look at the optimized code produced by the compiler [2].
>
> Cheers,
>
> Steve
>
> 1. http://lists.llvm.org/pipermail/llvm-dev/2016-February/095075.html
> 2. http://lists.llvm.org/pipermail/llvm-dev/2016-February/095265.html
>
> --
> Stephen Checkoway
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
More information about the llvm-dev
mailing list