Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

suggest: do not store the macro usages

(1/1)

ollydbg:
What's option about this simple patch:


--- Code: ---commit c8eb8932bf5047072b301f2db42fa980ec548de6
Author: asmwarrior <ollydbg@codeblocks.org>
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);

--- End code ---

oBFusCATed:
I don't understand what is the question.

ollydbg:

--- Quote from: oBFusCATed on February 27, 2015, 08:39:14 am ---I don't understand what is the question.

--- End quote ---

Let me explain:


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

--- End code ---

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.

Huki:
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.

ollydbg:

--- Quote from: Huki 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.

--- End quote ---
Hi, Huki, indeed this is another issue caused by macro usage tokens with the same name.
I committed my changes to the trunk, thanks.

Navigation

[0] Message Index

Go to full version