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

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


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

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


>From ea29d2505dc6e95e53a647cfb7b8bc9e9800beb9 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sat, 25 Oct 2025 13:01:44 -0700
Subject: [PATCH] [Support] Simplify control flow in percentDecode (NFC)

The "if" statement being removed in this patch is identical to the
"else" clause.
---
 llvm/lib/Support/LSP/Protocol.cpp | 4 ----
 1 file changed, 4 deletions(-)

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)));



More information about the llvm-commits mailing list