Skip to content

Commit 9bfc0b9

Browse files
committed
more efficient comparison with the colon string
1 parent b9b2a2e commit 9bfc0b9

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

pystring.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,7 +1089,7 @@ namespace path
10891089
void splitdrive_nt(std::string & drivespec, std::string & pathspec,
10901090
const std::string & p)
10911091
{
1092-
if(pystring::slice(p, 1, 2) == colon)
1092+
if (p.size() >= 2 && p[1] == ':')
10931093
{
10941094
std::string path = p; // In case drivespec == p
10951095
drivespec = pystring::slice(path, 0, 2);
@@ -1209,8 +1209,8 @@ namespace path
12091209
// 4. join('c:', 'd:/') = 'd:/'
12101210
// 5. join('c:/', 'd:/') = 'd:/'
12111211

1212-
if( (pystring::slice(path, 1, 2) != colon) ||
1213-
(pystring::slice(b, 1, 2) == colon) )
1212+
1213+
if ((path.size() >= 2 && path[1] != ':') || (b.size() >= 2 && b[1] == ':'))
12141214
{
12151215
// Path doesnt start with a drive letter
12161216
b_nts = true;

0 commit comments

Comments
 (0)