Author Topic: suggest: do not store the macro usages  (Read 3995 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5358
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
suggest: do not store the macro usages
« on: February 27, 2015, 07:41:08 am »
What's option about this simple patch:

Code
commit c8eb8932bf5047072b301f2db42fa980ec548de6
Author: asmwarrior <[email protected]>
Date:   Fri Feb 27 14:44:34 2015 +0800

    * CC: do not save the macro usage.
   
    macro usage is just like a function call, if we save all macro usages, our
    token tree becomes too large. E.g. with this patch, the token number is
    reduced from about 15000 to 13000 when parsing codeblocks.cbp. The only
    case we need to save the macro usage are some special macro usages like
    BEGIN_EVENT_TABLE or EVT_BUTTON, but this needs futures works.

diff --git a/src/plugins/codecompletion/parser/parserthread.cpp b/src/plugins/codecompletion/parser/parserthread.cpp
index 1d6f40e..cd5efee 100644
--- a/src/plugins/codecompletion/parser/parserthread.cpp
+++ b/src/plugins/codecompletion/parser/parserthread.cpp
@@ -2977,8 +2977,8 @@ void ParserThread::HandleMacroExpansion(int id, const wxString &peek)
     Token* tk = m_TokenTree->at(id);
     if (tk)
     {
-        TRACE(_T("HandleMacroExpansion() : Adding token '%s' (peek='%s')"), tk->m_Name.wx_str(), peek.wx_str());
-        DoAddToken(tkMacroUse, tk->m_Name, m_Tokenizer.GetLineNumber(), 0, 0, peek);
+        //TRACE(_T("HandleMacroExpansion() : Adding token '%s' (peek='%s')"), tk->m_Name.wx_str(), peek.wx_str());
+        //DoAddToken(tkMacroUse, tk->m_Name, m_Tokenizer.GetLineNumber(), 0, 0, peek);
 
         if (m_Options.parseComplexMacros)
             m_Tokenizer.ReplaceMacroUsage(tk);
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.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13402
    • Travis build status
Re: suggest: do not store the macro usages
« Reply #1 on: February 27, 2015, 08:39:14 am »
I don't understand what is the question.
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5358
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: suggest: do not store the macro usages
« Reply #2 on: February 27, 2015, 10:24:02 am »
I don't understand what is the question.

Let me explain:

Code
/* line 1 */  #define INT int
/* line 2 */  INT a;

In the above code, if we disable "storing macro usage", we have two tokens in the token tree:
1, macro definition token "#define INT int" in line 1
2, global variable token "a" in line 2

But currently enable "storing macro usage" will have another token in the tree:
3, macro usage token "INT" in line 2

I just means that such macro usage may happens too many times in source code(they just like functions calls), and we don't need to store them in the token tree to save memory usages.
« Last Edit: February 27, 2015, 10:26:18 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.

Offline Huki

  • Multiple posting newcomer
  • *
  • Posts: 95
Re: suggest: do not store the macro usages
« Reply #3 on: March 02, 2015, 04:24:44 pm »
I agree about this suggestion, I made this change myself long time ago. It will avoid polluting the tooltip when there are too many macro usages.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5358
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: suggest: do not store the macro usages
« Reply #4 on: March 05, 2015, 12:41:01 am »
I agree about this suggestion, I made this change myself long time ago. It will avoid polluting the tooltip when there are too many macro usages.
Hi, Huki, indeed this is another issue caused by macro usage tokens with the same name.
I committed my changes to the trunk, thanks.
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.