Skip to content

Commit 3a651bd

Browse files
committed
Replace c++ std::string starts_with instances with an ink internal alternative.
1 parent 7737194 commit 3a651bd

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

inkcpp_compiler/json_compiler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,8 @@ void json_compiler::compile_container(
138138
bool is_knot = name_override != "" && index_in_parent == -1;
139139
if (is_knot) {
140140
// it is not a wave or choice
141-
if (name_override.starts_with("c-") || name_override.starts_with("g-")) {
141+
if (::ink::internal::starts_with(name_override.c_str(), "c-") ||
142+
::ink::internal::starts_with(name_override.c_str(), "g-")) {
142143
is_knot = false;
143144
for (auto itr = name_override.begin() + 2; itr != name_override.end(); ++itr) {
144145
if (*itr > '9' || *itr < '0') {

shared/public/system.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,19 @@ constexpr list_flag empty_flag{-1, 0};
9797

9898
namespace internal
9999
{
100+
/** Checks if a string starts with a given prefix*/
101+
static bool starts_with(const char* string, const char* prefix)
102+
{
103+
while (*prefix) {
104+
if (*string != *prefix) {
105+
return false;
106+
}
107+
string++;
108+
prefix++;
109+
}
110+
return true;
111+
}
112+
100113
/** Checks if a string is only whitespace*/
101114
static bool is_whitespace(const char* string, bool includeNewline = true)
102115
{

0 commit comments

Comments
 (0)