This is an automated email from the ASF dual-hosted git repository.

wenming pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix.git


The following commit(s) were added to refs/heads/master by this push:
     new 01763b5dd perf(log-rotate): replace string.sub with string.byte (#9984)
01763b5dd is described below

commit 01763b5ddae1ba4f6d52778fad420aa4221c3c44
Author: Ruidong-X <[email protected]>
AuthorDate: Mon Aug 14 10:04:31 2023 +0800

    perf(log-rotate): replace string.sub with string.byte (#9984)
---
 apisix/plugins/log-rotate.lua | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/apisix/plugins/log-rotate.lua b/apisix/plugins/log-rotate.lua
index 14e4c45c7..db3360e44 100644
--- a/apisix/plugins/log-rotate.lua
+++ b/apisix/plugins/log-rotate.lua
@@ -33,6 +33,7 @@ local os_remove = os.remove
 local os_rename = os.rename
 local str_sub = string.sub
 local str_format = string.format
+local str_byte = string.byte
 local ngx_sleep = require("apisix.core.utils").sleep
 local string_rfind = require("pl.stringx").rfind
 local local_conf
@@ -48,6 +49,7 @@ local default_logs
 local enable_compression = false
 local DEFAULT_ACCESS_LOG_FILENAME = "access.log"
 local DEFAULT_ERROR_LOG_FILENAME = "error.log"
+local SLASH_BYTE = str_byte("/")
 
 local schema = {
     type = "object",
@@ -88,9 +90,8 @@ local function get_log_path_info(file_type)
     local prefix = ngx.config.prefix()
 
     if conf_path then
-        local root = str_sub(conf_path, 1, 1)
         -- relative path
-        if root ~= "/" then
+        if str_byte(conf_path) ~= SLASH_BYTE then
             conf_path = prefix .. conf_path
         end
         local n = string_rfind(conf_path, "/")

Reply via email to