[Lldb-commits] [lldb] r359138 - [ScriptInterpreterPython] find_first_of -> find (NFC)

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Thu Apr 25 10:10:33 PDT 2019


On 24/04/2019 22:40, Jonas Devlieghere via lldb-commits wrote:
> Author: jdevlieghere
> Date: Wed Apr 24 13:40:24 2019
> New Revision: 359138
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=359138&view=rev
> Log:
> [ScriptInterpreterPython] find_first_of -> find (NFC)
> 
> Follow up to r357198.
> 
> Modified:
>      lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
> 
> Modified: lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp?rev=359138&r1=359137&r2=359138&view=diff
> ==============================================================================
> --- lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp (original)
> +++ lldb/trunk/source/Plugins/ScriptInterpreter/Python/ScriptInterpreterPython.cpp Wed Apr 24 13:40:24 2019
> @@ -2869,7 +2869,8 @@ bool ScriptInterpreterPythonImpl::IsRese
>   
>     // filter out a few characters that would just confuse us and that are
>     // clearly not keyword material anyway
> -  if (word_sr.find_first_of("'\"") != llvm::StringRef::npos)
> +  if (word_sr.find('"') != llvm::StringRef::npos ||
> +      word_sr.find('\'') != llvm::StringRef::npos)
>       return false;
>   

I suppose that's a matter of opinion, but I actually found the original 
version clearer. I also wouldn't be surprised if the original version 
was faster or at least equally fast (as the character list is a 
compile-time constant, there's a lot of optimizations that can be done 
even with the `find` function.


More information about the lldb-commits mailing list