Skip to content

Commit

Permalink
[JavaScriptCore] strstr->strchr when string is only one letter long
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=267351

Reviewed by Michael Catanzaro.

Instead of having to find a whole string, we can just find the char we
need.

* Source/JavaScriptCore/runtime/Options.cpp: strstr->strchr
(JSC::Options::setOptions): Ditto.
* Source/JavaScriptCore/tools/FunctionOverrides.cpp: Ditto.
(JSC::parseClause): Ditto.

Canonical link: https://commits.webkit.org/272859@main
  • Loading branch information
RSilicon authored and mcatanzaro committed Jan 10, 2024
1 parent ff85ff1 commit 5d0b9ad
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/runtime/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ bool Options::setOptions(const char* optionsStr)
break;

char* optionStart = p;
p = strstr(p, "=");
p = strchr(p, '=');
if (!p) {
dataLogF("'=' not found in option string: %p\n", optionStart);
WTF::fastFree(optionsStrCopy);
Expand Down
2 changes: 1 addition & 1 deletion Source/JavaScriptCore/tools/FunctionOverrides.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ static String parseClause(const char* keyword, size_t keywordLength, FILE* file,
FAIL_WITH_ERROR(SYNTAX_ERROR, ("'", keyword, "' must be followed by a ' ':\n", line, "\n"));

const char* delimiterStart = &line[keywordLength + 1];
const char* delimiterEnd = strstr(delimiterStart, "{");
const char* delimiterEnd = strchr(delimiterStart, '{');
if (!delimiterEnd)
FAIL_WITH_ERROR(SYNTAX_ERROR, ("Missing { after '", keyword, "' clause start delimiter:\n", line, "\n"));

Expand Down

0 comments on commit 5d0b9ad

Please sign in to comment.