News:

The new Release 25.03 is out! You can download binaries for Windows and many major Linux distros here .

Main Menu

10-20s to open C::B's own project file on Windows.

Started by dmoore, October 28, 2013, 03:53:48 PM

Previous topic - Next topic

dmoore

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.next.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.


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
         {
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

MortenMacFly

Quote from: dmoore on October 28, 2013, 03:53:48 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: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]