optimize strIsContain and strPointToLastToken

This commit is contained in:
pikastech 2022-10-15 11:07:04 +08:00
parent 9ea03893b6
commit 24a6e50feb
2 changed files with 7 additions and 4 deletions

View File

@ -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;
}

View File

@ -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(),