aboutsummaryrefslogtreecommitdiff
path: root/src/cancel.cpp
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-05-20 15:57:03 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-05-20 15:57:03 +0200
commitac8caa415b36c875578c2ad0490965b80be2f37e (patch)
tree96bf4411f57452a74f0e566994a2ca103aef797a /src/cancel.cpp
parent9a0781e52fd0f9eac8ac75c18d7f58936fb6c981 (diff)
downloadlanes-ac8caa415b36c875578c2ad0490965b80be2f37e.tar.gz
lanes-ac8caa415b36c875578c2ad0490965b80be2f37e.tar.bz2
lanes-ac8caa415b36c875578c2ad0490965b80be2f37e.zip
More string_view
Diffstat (limited to 'src/cancel.cpp')
-rw-r--r--src/cancel.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/cancel.cpp b/src/cancel.cpp
index ff7af1e..f093905 100644
--- a/src/cancel.cpp
+++ b/src/cancel.cpp
@@ -162,20 +162,20 @@ CancelResult thread_cancel(Lane* lane_, CancelOp op_, int hookCount_, std::chron
162// ################################################################################################# 162// #################################################################################################
163// ################################################################################################# 163// #################################################################################################
164 164
165CancelOp which_cancel_op(char const* opString_) 165CancelOp which_cancel_op(std::string_view const& opString_)
166{ 166{
167 CancelOp _op{ CancelOp::Invalid }; 167 CancelOp _op{ CancelOp::Invalid };
168 if (strcmp(opString_, "hard") == 0) { 168 if (opString_ == "hard") {
169 _op = CancelOp::Hard; 169 _op = CancelOp::Hard;
170 } else if (strcmp(opString_, "soft") == 0) { 170 } else if (opString_ == "soft") {
171 _op = CancelOp::Soft; 171 _op = CancelOp::Soft;
172 } else if (strcmp(opString_, "call") == 0) { 172 } else if (opString_== "call") {
173 _op = CancelOp::MaskCall; 173 _op = CancelOp::MaskCall;
174 } else if (strcmp(opString_, "ret") == 0) { 174 } else if (opString_ == "ret") {
175 _op = CancelOp::MaskRet; 175 _op = CancelOp::MaskRet;
176 } else if (strcmp(opString_, "line") == 0) { 176 } else if (opString_ == "line") {
177 _op = CancelOp::MaskLine; 177 _op = CancelOp::MaskLine;
178 } else if (strcmp(opString_, "count") == 0) { 178 } else if (opString_ == "count") {
179 _op = CancelOp::MaskCount; 179 _op = CancelOp::MaskCount;
180 } 180 }
181 return _op; 181 return _op;
@@ -186,7 +186,7 @@ CancelOp which_cancel_op(char const* opString_)
186[[nodiscard]] static CancelOp which_cancel_op(lua_State* L_, int idx_) 186[[nodiscard]] static CancelOp which_cancel_op(lua_State* L_, int idx_)
187{ 187{
188 if (lua_type(L_, idx_) == LUA_TSTRING) { 188 if (lua_type(L_, idx_) == LUA_TSTRING) {
189 char const* const _str{ lua_tostring(L_, idx_) }; 189 std::string_view const _str{ lua_tostringview(L_, idx_) };
190 CancelOp _op{ which_cancel_op(_str) }; 190 CancelOp _op{ which_cancel_op(_str) };
191 lua_remove(L_, idx_); // argument is processed, remove it 191 lua_remove(L_, idx_); // argument is processed, remove it
192 if (_op == CancelOp::Invalid) { 192 if (_op == CancelOp::Invalid) {