Author Topic: 10-20s to open C::B's own project file on Windows.  (Read 4635 times)

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
10-20s to open C::B's own project file on Windows.
« on: October 28, 2013, 03:53:48 pm »
and up to a minute for the workspace! Is this just me or does anyone else have these problems?

This has been discussed in the past here: http://forums.codeblocks.org/index.php/topic,16967.90.html

Something like this small patch would reduce the abundance MakeRelativeTo calls that are really slow on windows for normal project layouts... e.g. it cuts the C::B project load time to a few seconds.

Code
Index: src/sdk/cbproject.cpp
===================================================================
--- src/sdk/cbproject.cpp (revision 9423)
+++ src/sdk/cbproject.cpp (working copy)
@@ -391,19 +391,23 @@
                 && !fileHasUNCName
                 && vol.IsSameAs(f->file.GetVolume()) ) )
         {
-            wxFileName relFileCTLP(f->file);
-            relFileCTLP.MakeRelativeTo( m_CommonTopLevelPath );
-            wxFileName relFileBase(f->file);
-            relFileBase.MakeRelativeTo( GetBasePath() );
+            if (!fileName.StartsWith(m_CommonTopLevelPath))
+            {
+                wxFileName relFileCTLP(f->file);
+                relFileCTLP.MakeRelativeTo( m_CommonTopLevelPath );
+                f->relativeToCommonTopLevelPath = relFileCTLP.GetFullPath();
+            }
+            else
+                f->relativeToCommonTopLevelPath = fileName.Right(fileName.Length() - m_CommonTopLevelPath.Length());
 
-            // The commented (old) method to obtain the relativeToCommonTopLevelPath is fast, but does *not* work, if you save
-            // the project on a different drive in a sub-folder of an existing source file on that (different) drive:
-            // I.e.: Project on C:\Folder\Project.cbp has file C:\Folder\SubFolder\foo.cpp and D:\Folder\bar.cpp
-            // Saved the project under D:\Folder\SubFolder\ProjectNew.cbp would cause a wrong computation of bar.cpp otherwise!!!
-//            f->relativeToCommonTopLevelPath = fileName.Right(fileName.Length() - m_CommonTopLevelPath.Length());
-            // Using wxFileName instead, although its costly:
-            f->relativeToCommonTopLevelPath = relFileCTLP.GetFullPath();
-            f->relativeFilename             = relFileBase.GetFullPath();
+            if (!fileName.StartsWith(GetBasePath()))
+            {
+                wxFileName relFileBase(f->file);
+                relFileBase.MakeRelativeTo( GetBasePath() );
+                f->relativeFilename             = relFileBase.GetFullPath();
+            }
+            else
+                f->relativeFilename = fileName.Right(fileName.Length() - GetBasePath().Length());
         }
         else
         {

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9694
Re: 10-20s to open C::B's own project file on Windows.
« Reply #1 on: November 05, 2013, 07:00:14 pm »
Something like this small patch would reduce the abundance MakeRelativeTo calls that are really slow on windows for normal project layouts... e.g. it cuts the C::B project load time to a few seconds.
Be sure to well test it including all platforms, macros, network shares. Thats the main reason why its implemented like this.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ