forked from qt-creator/qt-creator
		
	C++: use argumentCount in loops in initializer.
argumentCount is a more expensive function, so try to call it only once, esp. in loops. Change-Id: I6f0d420352743ec444487ce3f506ef28e5282d1e Reviewed-by: Nikolai Kosjar <nikolai.kosjar@digia.com>
This commit is contained in:
		@@ -1364,7 +1364,7 @@ void CppCompletionAssistProcessor::globalCompletion(CPlusPlus::Scope *currentSco
 | 
			
		||||
            }
 | 
			
		||||
        } else if (scope->isFunction()) {
 | 
			
		||||
            Function *fun = scope->asFunction();
 | 
			
		||||
            for (unsigned i = 0; i < fun->argumentCount(); ++i) {
 | 
			
		||||
            for (unsigned i = 0, argc = fun->argumentCount(); i < argc; ++i) {
 | 
			
		||||
                addCompletionItem(fun->argumentAt(i), FunctionArgumentsOrder);
 | 
			
		||||
            }
 | 
			
		||||
            break;
 | 
			
		||||
 
 | 
			
		||||
@@ -185,15 +185,16 @@ Symbol *SymbolFinder::findMatchingDefinition(Symbol *declaration,
 | 
			
		||||
                    if (! strict && ! best)
 | 
			
		||||
                        best = fun;
 | 
			
		||||
 | 
			
		||||
                    unsigned argc = 0;
 | 
			
		||||
                    for (; argc < declarationTy->argumentCount(); ++argc) {
 | 
			
		||||
                        Symbol *arg = fun->argumentAt(argc);
 | 
			
		||||
                        Symbol *otherArg = declarationTy->argumentAt(argc);
 | 
			
		||||
                    const unsigned argc = declarationTy->argumentCount();
 | 
			
		||||
                    unsigned argIt = 0;
 | 
			
		||||
                    for (; argIt < argc; ++argIt) {
 | 
			
		||||
                        Symbol *arg = fun->argumentAt(argIt);
 | 
			
		||||
                        Symbol *otherArg = declarationTy->argumentAt(argIt);
 | 
			
		||||
                        if (! arg->type().isEqualTo(otherArg->type()))
 | 
			
		||||
                            break;
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                    if (argc == declarationTy->argumentCount())
 | 
			
		||||
                    if (argIt == argc)
 | 
			
		||||
                        best = fun;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user