[llvm] [Support] Simplify control flow in percentDecode (NFC) (PR #165134)

via llvm-commits llvm-commits at lists.llvm.org
Sat Oct 25 23:27:47 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-support

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

The "if" statement being removed in this patch is identical to the
"else" clause.


---
Full diff: https://github.com/llvm/llvm-project/pull/165134.diff


1 Files Affected:

- (modified) llvm/lib/Support/LSP/Protocol.cpp (-4) 


``````````diff
diff --git a/llvm/lib/Support/LSP/Protocol.cpp b/llvm/lib/Support/LSP/Protocol.cpp
index f22126345a435..f8eeb32db02ab 100644
--- a/llvm/lib/Support/LSP/Protocol.cpp
+++ b/llvm/lib/Support/LSP/Protocol.cpp
@@ -96,10 +96,6 @@ static void percentEncode(StringRef Content, std::string &Out) {
 static std::string percentDecode(StringRef Content) {
   std::string Result;
   for (auto I = Content.begin(), E = Content.end(); I != E; ++I) {
-    if (*I != '%') {
-      Result += *I;
-      continue;
-    }
     if (*I == '%' && I + 2 < Content.end() && llvm::isHexDigit(*(I + 1)) &&
         llvm::isHexDigit(*(I + 2))) {
       Result.push_back(llvm::hexFromNibbles(*(I + 1), *(I + 2)));

``````````

</details>


https://github.com/llvm/llvm-project/pull/165134


More information about the llvm-commits mailing list