Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Adam Johnson <[email protected]>
  • Loading branch information
dgelessus and Hoikas committed Oct 16, 2023
1 parent 8d62099 commit 818f018
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions Sources/Plasma/CoreLib/hsStringTokenizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ You can contact Cyan Worlds, Inc. by email [email protected]

#include "HeadSpin.h"

#include <string>

template<typename CharT>
class hsBasicStringTokenizer
{
Expand Down Expand Up @@ -132,18 +134,20 @@ class hsBasicStringTokenizer
{
delete[] fString;
if (string) {
size_t count = StrLen(string);
size_t count = std::char_traits<CharT>::length(string);
fString = new CharT[count + 1];
memcpy(fString, string, sizeof(CharT) * (count + 1));
std::char_traits<CharT>::copy(fString, string, count);
fString[count] = 0;
} else {
fString = nullptr;
}

delete[] fSeps;
if (seps) {
fNumSeps = StrLen(seps);
fNumSeps = std::char_traits<CharT>::length(seps);
fSeps = new CharT[fNumSeps + 1];
memcpy(fSeps, seps, sizeof(CharT) * (fNumSeps + 1));
std::char_traits<CharT>::copy(fSeps, seps, fNumSeps);
fSeps[fNumSeps] = 0;
} else {
fNumSeps = 0;
fSeps = nullptr;
Expand Down Expand Up @@ -174,15 +178,6 @@ class hsBasicStringTokenizer
CharT* fString;

private:
static size_t StrLen(const CharT* str)
{
size_t i = 0;
while (str[i] != 0) {
i++;
}
return i;
}

bool IsSep(CharT c)
{
if (!fQAsTok || !fInQuote) {
Expand Down

0 comments on commit 818f018

Please sign in to comment.