You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kvrocks.apache.org by GitBox <gi...@apache.org> on 2022/06/20 08:35:24 UTC

[GitHub] [incubator-kvrocks] PragmaTwice commented on a diff in pull request #642: [fix]:load namespace from config file with case-sensitive issue:#640

PragmaTwice commented on code in PR #642:
URL: https://github.com/apache/incubator-kvrocks/pull/642#discussion_r901399201


##########
src/config.cc:
##########
@@ -523,17 +523,19 @@ Status Config::parseConfigFromString(std::string input, int line_number) {
   if (kv.size() != 2) return Status(Status::NotOK, "wrong number of arguments");
   if (kv[1] == "\"\"") return Status::OK();
 
-  kv[0] = Util::ToLower(kv[0]);
-  auto iter = fields_.find(kv[0]);
+  std::string configKey = Util::ToLower(kv[0]);
+  if (!strncasecmp(kv[0].data(), "namespace.", 10)) {
+      // namespace should keep key case-sensitive
+      configKey = kv[0];
+      tokens[kv[1]] = kv[0].substr(10, kv[0].size() - 10);
+  }

Review Comment:
   ```suggestion
     const char ns_str[] = "namespace.";
     size_t ns_str_size = sizeof(ns_str) - 1;
     if (!strncasecmp(kv[0].data(), ns_str, ns_str_size)) {
         // namespace should keep key case-sensitive
         configKey = kv[0];
         tokens[kv[1]] = kv[0].substr(ns_str_size);
     }
   ```
   I think we should avoid any magic number, e.g. `10` here : )



-- 
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: issues-unsubscribe@kvrocks.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org