Author Topic: unknown comments in CC, I'm going to remove it  (Read 10423 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6034
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
unknown comments in CC, I'm going to remove it
« on: May 13, 2014, 05:33:06 am »
Currently in CC code, we have codecompletion.cpp
Code
void CodeCompletion::DoParseOpenedProjectAndActiveEditor()
{
    // Let the app startup before parsing
    // This is to prevent the Splash Screen from delaying so much. By adding
    // the timer, the splash screen is closed and Code::Blocks doesn't take
    // so long in starting.
    m_InitDone = true;
When I read the comment, I wander why those comments are used for, where is the timer?

Use the git log -S command, I find that this piece of comment is useless, also, I even don't know what does m_InitDone used for.

First line of the comment comes from this commit
Code
Revision: 8080bfca289338ecfa74cf13dd10c4ae96cc0e64
Author: rickg22 <rickg22@2a5c6006-c6dd-42ca-98ab-0921f2732cef>
Date: 2006-1-23 14:14:56
Message:
Removed (yet another) bottleneck in Codecompletion with global includes.

Removed (confirmed now) 5-second delay at startup with Codecompletion enabled.

git-svn-id: http://svn.code.sf.net/p/codeblocks/code/trunk@1840 2a5c6006-c6dd-42ca-98ab-0921f2732cef
----
Modified: src/plugins/codecompletion/codecompletion.cpp
Modified: src/plugins/codecompletion/codecompletion.h
Modified: src/plugins/codecompletion/parser/parser.cpp
Modified: src/plugins/codecompletion/parser/parser.h
Modified: src/plugins/codecompletion/parser/parserthread.cpp
Modified: src/plugins/codecompletion/parser/parserthread.h

+void CodeCompletion::OnAppDoneStartup(CodeBlocksEvent& event)
+{
+    // Let the app startup before parsing
+    m_timer.Start(200,wxTIMER_ONE_SHOT);
+}
+
+void CodeCompletion::OnStartParsingProjects(wxTimerEvent& event)
+{
+ // parse all active projects
+ ProjectManager* prjMan = Manager::Get()->GetProjectManager();
+ for (unsigned int i = 0; i < prjMan->GetProjects()->GetCount(); ++i)
+ m_NativeParsers.AddParser(prjMan->GetProjects()->Item(i));
+    m_InitDone = true;
+}
+

Then the following comments added
Code
Revision: e0984616b05114099c4a894120e5bcbbfb1706e1
Author: rickg22 <rickg22@2a5c6006-c6dd-42ca-98ab-0921f2732cef>
Date: 2006-1-27 12:42:32
Message:
SDK (cbThreadPool): Rewrote threads code to fix the  50% CPU issue with dual core CPU's.

Code completion: Fixed a number of issues dealing with threads.
App: Added "Initializing plugins" message.

git-svn-id: http://svn.code.sf.net/p/codeblocks/code/trunk@1880 2a5c6006-c6dd-42ca-98ab-0921f2732cef
----
Modified: src/plugins/codecompletion/codecompletion.cpp
Modified: src/plugins/codecompletion/nativeparser.cpp
Modified: src/plugins/codecompletion/parser/parser.cpp
Modified: src/plugins/codecompletion/parser/parser.h
Modified: src/plugins/codecompletion/parser/parserthread.cpp
Modified: src/plugins/codecompletion/parser/parserthread.h
Modified: src/sdk/cbthreadpool.cpp
Modified: src/sdk/cbthreadpool.h
Modified: src/src/app.cpp
 src/plugins/codecompletion/codecompletion.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/plugins/codecompletion/codecompletion.cpp b/src/plugins/codecompletion/codecompletion.cpp
index 92f1d09..85971a3 100644
--- a/src/plugins/codecompletion/codecompletion.cpp
+++ b/src/plugins/codecompletion/codecompletion.cpp
@@ -107,7 +107,7 @@ m_timer(this, idStartParsingProjects)
     m_PluginInfo.thanksTo = _T("");
 
     m_PageIndex = -1;
-    m_InitDone = true;
+    m_InitDone = false;
     m_EditMenu = 0L;
  m_SearchMenu = 0L;
 }
@@ -597,6 +597,9 @@ void CodeCompletion::DoInsertCodeCompleteToken(wxString tokName)
 void CodeCompletion::OnAppDoneStartup(CodeBlocksEvent& event)
 {
     // Let the app startup before parsing
+    // This is to prevent the Splash Screen from delaying so much. By adding the
+    // timer, the splash screen is closed and Code::Blocks doesn't take so long
+    // in starting.
     m_timer.Start(200,wxTIMER_ONE_SHOT);
 }
 

And finally the m_timer is removed
Code
Revision: c7ff2ff85ddad5c6c99371d7df6959777c934568
Author: rickg22 <rickg22@2a5c6006-c6dd-42ca-98ab-0921f2732cef>
Date: 2007-6-25 11:26:31
Message:
* Code Completion: Fixed recent bug that prevented the symbol tree from being updated. Also removed some obsolete code.

git-svn-id: http://svn.code.sf.net/p/codeblocks/code/trunk@4168 2a5c6006-c6dd-42ca-98ab-0921f2732cef
----
Modified: src/plugins/codecompletion/codecompletion.cpp
Modified: src/plugins/codecompletion/codecompletion.h
@@ -957,7 +963,6 @@ void CodeCompletion::OnAppDoneStartup(CodeBlocksEvent& event)
     // This is to prevent the Splash Screen from delaying so much. By adding the
     // timer, the splash screen is closed and Code::Blocks doesn't take so long
     // in starting.
-    m_timer.Start(200, wxTIMER_ONE_SHOT);
     event.Skip();
 }

OK, but the comments leaves there for a very long time, they move from one function to another, and even get refined.

It looks like the timer is used to delay running the parser after the whole C::B is started. Not the case where C::B is started with no project opened, mostly used for the case where you double click on a cbp icon, and C::B started with the project opened.

I'm going to clear those comments.
« Last Edit: May 13, 2014, 05:36:46 am by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.