Avoid a string copy and a small tweak.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@29837 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Enrico Forestieri 2009-05-24 21:09:41 +00:00
parent 8955a6cad9
commit e2c763d9f6
3 changed files with 6 additions and 9 deletions

View File

@ -171,8 +171,7 @@ docstring::size_type common_path(docstring const & p1, docstring const & p2)
bool path_prefix_is(string const & path, string const & pre) bool path_prefix_is(string const & path, string const & pre)
{ {
string tmp = path; return path_prefix_is(const_cast<string &>(path), pre, CASE_UNCHANGED);
return path_prefix_is(tmp, pre, CASE_UNCHANGED);
} }
@ -182,7 +181,7 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
docstring const p2 = from_utf8(pre); docstring const p2 = from_utf8(pre);
docstring::size_type i = common_path(p1, p2); docstring::size_type i = common_path(p1, p2);
if (i + 1 != p2.length()) if (i == 0 || i + 1 != p2.length())
return false; return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre)) if (how == CASE_ADJUSTED && !prefixIs(path, pre))

View File

@ -80,8 +80,7 @@ docstring::size_type common_path(docstring const & p1, docstring const & p2)
bool path_prefix_is(string const & path, string const & pre) bool path_prefix_is(string const & path, string const & pre)
{ {
#ifdef __APPLE__ #ifdef __APPLE__
string tmp = path; return path_prefix_is(const_cast<string &>(path), pre, CASE_UNCHANGED);
return path_prefix_is(tmp, pre, CASE_UNCHANGED);
#else #else
return prefixIs(path, pre); return prefixIs(path, pre);
#endif #endif
@ -95,7 +94,7 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
docstring const p2 = from_utf8(pre); docstring const p2 = from_utf8(pre);
docstring::size_type i = common_path(p1, p2); docstring::size_type i = common_path(p1, p2);
if (i + 1 != p2.length()) if (i == 0 || i + 1 != p2.length())
return false; return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre)) if (how == CASE_ADJUSTED && !prefixIs(path, pre))

View File

@ -202,8 +202,7 @@ docstring::size_type common_path(docstring const & p1, docstring const & p2)
bool path_prefix_is(string const & path, string const & pre) bool path_prefix_is(string const & path, string const & pre)
{ {
string tmp = path; return path_prefix_is(const_cast<string &>(path), pre, CASE_UNCHANGED);
return path_prefix_is(tmp, pre, CASE_UNCHANGED);
} }
@ -213,7 +212,7 @@ bool path_prefix_is(string & path, string const & pre, path_case how)
docstring const p2 = from_utf8(pre); docstring const p2 = from_utf8(pre);
docstring::size_type i = common_path(p1, p2); docstring::size_type i = common_path(p1, p2);
if (i + 1 != p2.length()) if (i == 0 || i + 1 != p2.length())
return false; return false;
if (how == CASE_ADJUSTED && !prefixIs(path, pre)) if (how == CASE_ADJUSTED && !prefixIs(path, pre))