[llvm-dev] StringSwitch efficiency

Stephen Checkoway via llvm-dev llvm-dev at lists.llvm.org
Wed Oct 28 21:01:06 PDT 2020



> 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





More information about the llvm-dev mailing list