Skip to content

Commit

Permalink
Added comment (all string functions seem to be now at the speed limit…
Browse files Browse the repository at this point in the history
… given the use of std::string instead of char*)
  • Loading branch information
GillesDuvert committed Aug 28, 2023
1 parent 43b7bf3 commit fb677b0
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions src/basic_fun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2301,6 +2301,7 @@ namespace lib {
return res;
}

//GD: cannot be made faster if we keep using std::string . Performance is not good wrt idl.
BaseGDL* strjoin(EnvT* e) {
SizeT nParam = e->NParam(1);

Expand Down Expand Up @@ -7282,16 +7283,18 @@ namespace lib {
if (regex && e->KeywordPresent(ESCAPEIx)) e->Throw("Conflicting keywords.");
if (foldCaseKW && e->KeywordPresent(ESCAPEIx)) e->Throw("Conflicting keywords.");

e->AssureStringScalarKWIfPresent(ESCAPEIx, escape);
vector<long> escList;
long pos = 0;
while (pos != string::npos) {
pos = stringIn.find_first_of(escape, pos);
if (pos != string::npos) {
escList.push_back(pos + 1); // remember escaped char
pos += 2; // skip escaped char
}
}
if (e->KeywordSet(ESCAPEIx)) {
e->AssureStringScalarKWIfPresent(ESCAPEIx, escape); //must be a singleton.

Check warning on line 7288 in src/basic_fun.cpp

View check run for this annotation

Codecov / codecov/patch

src/basic_fun.cpp#L7288

Added line #L7288 was not covered by tests
size_t pos = 0;
while (pos != std::string::npos) {
pos = stringIn.find_first_of(escape, pos);
if (pos != string::npos) {
escList.push_back(pos + 1); // remember escaped char
pos += 2; // skip escaped char

Check warning on line 7294 in src/basic_fun.cpp

View check run for this annotation

Codecov / codecov/patch

src/basic_fun.cpp#L7293-L7294

Added lines #L7293 - L7294 were not covered by tests
}
}
}
vector<long>::iterator escBeg = escList.begin();
vector<long>::iterator escEnd = escList.end();

Expand Down

0 comments on commit fb677b0

Please sign in to comment.