aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-05 23:07:51 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-01-05 23:07:51 +0000
commit5df3b7cbfb4fa6cc61537170f59d9240ddb7b724 (patch)
tree216440efc4af5f5b0d5230b55620d191aac93364
parent979e09b334ea9a3f888ebfc65378c6dba5eb798d (diff)
downloadpaludis-5df3b7cbfb4fa6cc61537170f59d9240ddb7b724.tar.gz
paludis-5df3b7cbfb4fa6cc61537170f59d9240ddb7b724.tar.xz
Speed up FSEntry
-rw-r--r--paludis/util/fs_entry.cc38
1 files changed, 24 insertions, 14 deletions
diff --git a/paludis/util/fs_entry.cc b/paludis/util/fs_entry.cc
index 1d6c8d8..d174279 100644
--- a/paludis/util/fs_entry.cc
+++ b/paludis/util/fs_entry.cc
@@ -93,9 +93,16 @@ FSEntry::operator/ (const std::string & rhs) const
const FSEntry &
FSEntry::operator/= (const FSEntry & rhs)
{
- _path.append("/");
- _path.append(rhs._path);
- _normalise();
+ if (_path.empty() || '/' != _path.at(_path.length() - 1))
+ _path.append("/");
+
+ if (! rhs._path.empty())
+ {
+ if ('/' == rhs._path.at(0))
+ _path.append(rhs._path.substr(1));
+ else
+ _path.append(rhs._path);
+ }
_checked = false;
_exists = false;
@@ -216,21 +223,24 @@ FSEntry::_normalise()
{
try
{
- std::string new_path;
- std::string::size_type p(0);
- while (p < _path.length())
+ if (std::string::npos != _path.find("//"))
{
- if ('/' == _path[p])
+ std::string new_path;
+ std::string::size_type p(0);
+ while (p < _path.length())
{
- new_path += '/';
- while (++p < _path.length())
- if ('/' != _path[p])
- break;
+ if ('/' == _path[p])
+ {
+ new_path += '/';
+ while (++p < _path.length())
+ if ('/' != _path[p])
+ break;
+ }
+ else
+ new_path += _path[p++];
}
- else
- new_path += _path[p++];
+ _path = new_path;
}
- _path = new_path;
if (! _path.empty())
if ('/' == _path.at(_path.length() - 1))