From 24a6e50febfbd40a865ee00b75da01e2d4fb9d64 Mon Sep 17 00:00:00 2001 From: pikastech Date: Sat, 15 Oct 2022 11:07:04 +0800 Subject: [PATCH] optimize strIsContain and strPointToLastToken --- src/dataString.c | 9 ++++++--- tools/pikaCompiler/src/method_info.rs | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/dataString.c b/src/dataString.c index 5d58bbab2..8f4478d3e 100644 --- a/src/dataString.c +++ b/src/dataString.c @@ -111,6 +111,9 @@ size_t strGetSize(char* pData) { } char* strPointToLastToken(char* strIn, char sign) { + if(!strIsContain(strIn, sign)){ + return strIn; + } int32_t size = strGetSize(strIn); for (int32_t i = size - 1; i > -1; i--) { if (strIn[i] == sign) { @@ -214,11 +217,11 @@ char* strRemovePrefix(char* inputStr, char* prefix, char* outputStr) { } int32_t strIsContain(char* str, char ch) { - size_t len = strGetSize(str); - for (uint32_t i = 0; i < len; i++) { - if (str[i] == ch) { + while(*str){ + if (*str == ch){ return 1; } + str++; } return 0; } diff --git a/tools/pikaCompiler/src/method_info.rs b/tools/pikaCompiler/src/method_info.rs index 5aadf0659..7de18c1d0 100644 --- a/tools/pikaCompiler/src/method_info.rs +++ b/tools/pikaCompiler/src/method_info.rs @@ -85,7 +85,7 @@ impl MethodInfo { define.push_str( format!( - " {}(self, \"{}\", \"{}\", \n {}_{}Method);\n", + " {}(self, \"{}\", \"{}\", \n {}_{}Method);\n\n", class_define_method, self.name, arg_list, self.class_name, self.name ) .as_str(),