Copilot commented on code in PR #3396:
URL: https://github.com/apache/brpc/pull/3396#discussion_r3612316326


##########
BUILD.bazel:
##########
@@ -128,7 +128,6 @@ BUTIL_SRCS = [
     "src/butil/third_party/icu/icu_utf.cc",
     "src/butil/third_party/superfasthash/superfasthash.c",
     "src/butil/third_party/modp_b64/modp_b64.cc",
-    "src/butil/third_party/modp_b64/modp_b64_rvv.cc",
     "src/butil/third_party/symbolize/demangle.cc",
     "src/butil/third_party/symbolize/symbolize.cc",

Review Comment:
   `modp_b64.cc` calls RVV base64 helpers when `__riscv_vector` is enabled, but 
`BUILD.bazel` no longer compiles `modp_b64_rvv.cc`. This will cause unresolved 
symbols (e.g. `rvv_modp_b64_encode/decode`) for Bazel builds on RVV-enabled 
RISC-V.



##########
src/butil/string_compare_rvv.cc:
##########
@@ -0,0 +1,76 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+// RVV-accelerated memcmp for StringPiece operations.
+// Algorithm follows glibc's RVV memcmp pattern:
+// - e8m8 LMUL with hardware-adaptive VL via vsetvl
+// - vfirst.m for early-out on first mismatch
+

Review Comment:
   File header comment says this is an RVV-accelerated memcmp implementation, 
but this file now also implements `rvv_memchr()`. Keeping the comment accurate 
helps future maintenance and avoids confusion about what lives in this TU.



##########
src/butil/strings/string_piece.cc:
##########
@@ -134,7 +134,18 @@ size_t findT(const BasicStringPiece<STR>& self,
 }
 
 size_t find(const StringPiece& self, char c, size_t pos) {
+#if defined(__riscv) && defined(__riscv_vector)
+  if (pos < self.size()) {
+    const void* result = butil::rvv_memchr(self.data() + pos, c, self.size() - 
pos);
+    if (result != nullptr) {
+      return static_cast<const char*>(result) - self.data();
+    }
+    return BasicStringPiece<std::string>::npos;

Review Comment:
   This returns a pointer difference (`ptrdiff_t`) as `size_t` via implicit 
conversion. Casting explicitly to `size_t` matches the style used elsewhere in 
this file (see `findT` above) and avoids potential sign-conversion warnings 
under stricter build flags.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to