Skip to content

Commit 2f3da48

Browse files
MichaelChiricojimhester
authored andcommitted
find(':') is more efficient than find(":")
See https://clang.llvm.org/extra/clang-tidy/checks/performance-faster-string-find.html I'm not sure if the efficiency improvement is compiler-specific.
1 parent 02132a0 commit 2f3da48

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/xml2_node.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ extern "C" SEXP node_attr(
112112
if (Rf_xlength(nsMap_sxp) == 0) {
113113
string = xmlGetProp(node.checked_get(), asXmlChar(name));
114114
} else {
115-
size_t colon = name.find(":");
115+
size_t colon = name.find(':');
116116
if (colon == std::string::npos) {
117117
// Has namespace spec, but attribute not qualified, so look for attribute
118118
// without namespace
@@ -346,7 +346,7 @@ extern "C" SEXP node_set_attr(SEXP node_sxp, SEXP name_sxp, SEXP value, SEXP nsM
346346
if (Rf_xlength(nsMap) == 0) {
347347
xmlSetProp(node, asXmlChar(name), asXmlChar(value));
348348
} else {
349-
size_t colon = name.find(":");
349+
size_t colon = name.find(':');
350350
if (colon == std::string::npos) {
351351
// Has namespace spec, but attribute not qualified, so just use that name
352352
xmlSetProp(node, asXmlChar(name), asXmlChar(value));
@@ -389,7 +389,7 @@ extern "C" SEXP node_remove_attr(SEXP node_sxp, SEXP name_sxp, SEXP nsMap) {
389389
if (Rf_xlength(nsMap) == 0) {
390390
xmlUnsetProp(node, asXmlChar(name));
391391
} else {
392-
size_t colon = name.find(":");
392+
size_t colon = name.find(':');
393393
if (colon == std::string::npos) {
394394
// Has namespace spec, but attribute not qualified, so just use that name
395395
xmlUnsetNsProp(node, NULL, asXmlChar(name));

0 commit comments

Comments
 (0)