diff --git a/SystemTools.cxx b/SystemTools.cxx
index bef8d846db21db37f2432b8c714186c5c8479806..e657f6905c88855cfd44f44845bf59bffe21e101 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -3563,6 +3563,13 @@ SystemTools
 {
   // Construct result in a single string.
   kwsys_stl::string result;
+  size_t len = 0;
+  kwsys_stl::vector<kwsys_stl::string>::const_iterator i;
+  for(i = first; i != last; ++i)
+    {
+    len += 1 + i->size();
+    }
+  result.reserve(len);
 
   // The first two components do not add a slash.
   if(first != last)