diff options
| author | ruki <[email protected]> | 2025-11-10 21:00:21 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2025-11-10 21:00:21 +0800 |
| commit | 2c387895657ae13cd717d7f42f5baed5eb028a8e (patch) | |
| tree | 8f005a8dfc3272e9f027560e5e1b5881a7a8bc70 /core/src/xmake/string/split.c | |
| parent | 831447a51da0b094e08bb047247bf269a6e6cf71 (diff) | |
format more if-else codes in core
Diffstat (limited to 'core/src/xmake/string/split.c')
| -rw-r--r-- | core/src/xmake/string/split.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/core/src/xmake/string/split.c b/core/src/xmake/string/split.c index 56e8a636d..5ca0c92bb 100644 --- a/core/src/xmake/string/split.c +++ b/core/src/xmake/string/split.c @@ -45,8 +45,9 @@ static tb_void_t xm_string_split_str(lua_State *lua, tb_char_t const *pos = tb_strstr(cstr, cdls); // faster than tb_strnstr() while (pos && pos < end) { if (pos > cstr || strict) { - if (limit > 0 && num + 1 >= limit) + if (limit > 0 && num + 1 >= limit) { break; + } lua_pushlstring(lua, cstr, pos - cstr); lua_rawseti(lua, -2, ++num); @@ -70,8 +71,9 @@ static tb_void_t xm_string_split_chr( tb_char_t const *pos = tb_strchr(cstr, ch); // faster than tb_strnchr() while (pos && pos < end) { if (pos > cstr || strict) { - if (limit > 0 && num + 1 >= limit) + if (limit > 0 && num + 1 >= limit) { break; + } lua_pushlstring(lua, cstr, pos - cstr); lua_rawseti(lua, -2, ++num); @@ -119,9 +121,10 @@ tb_int_t xm_string_split(lua_State *lua) { // split it lua_newtable(lua); - if (ndls == 1) + if (ndls == 1) { xm_string_split_chr(lua, cstr, (tb_size_t)nstr, cdls[0], strict, limit); - else + } else { xm_string_split_str(lua, cstr, (tb_size_t)nstr, cdls, ndls, strict, limit); + } return 1; } |
