StringView constexpr. (#351)

This commit is contained in:
Branimir Karadžić
2025-11-22 18:41:54 -08:00
committed by GitHub
parent 0e221f9844
commit 808aa150f8
8 changed files with 281 additions and 138 deletions

View File

@@ -1093,7 +1093,7 @@ namespace bx
return true;
}
bool fromString(int32_t* _out, const StringView& _str)
bool fromString(long long* _out, const StringView& _str)
{
StringView str = strLTrimSpace(_str);
@@ -1113,7 +1113,7 @@ namespace bx
break;
}
int32_t result = 0;
long long result = 0;
for (ch = *ptr++; isNumeric(ch) && ptr <= term; ch = *ptr++)
{
@@ -1125,10 +1125,4 @@ namespace bx
return true;
}
bool fromString(uint32_t* _out, const StringView& _str)
{
fromString( (int32_t*)_out, _str);
return true;
}
} // namespace bx

View File

@@ -165,7 +165,7 @@ namespace bx
typedef char (*CharFn)(char _ch);
inline char toNoop(char _ch)
inline constexpr char toNoop(char _ch)
{
return _ch;
}
@@ -290,18 +290,6 @@ namespace bx
);
}
int32_t strLen(const char* _str, int32_t _max)
{
if (NULL == _str)
{
return 0;
}
const char* ptr = _str;
for (; 0 < _max && *ptr != '\0'; ++ptr, --_max) {};
return int32_t(ptr - _str);
}
inline int32_t strCopy(char* _dst, int32_t _dstSize, const char* _src, int32_t _num)
{
BX_ASSERT(NULL != _dst, "_dst can't be NULL!");