From ba2cfd157b2b5fcc297f476a945fef0e8eb66a79 Mon Sep 17 00:00:00 2001 From: john30 Date: Sat, 19 Nov 2016 12:24:25 +0100 Subject: [PATCH] removed extra function call overhead again --- src/ebusd/main.cpp | 13 +------------ src/lib/ebus/message.cpp | 10 +++++----- src/lib/ebus/message.h | 8 +++----- 3 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/ebusd/main.cpp b/src/ebusd/main.cpp index dea2eb4d..ede4d9d7 100644 --- a/src/ebusd/main.cpp +++ b/src/ebusd/main.cpp @@ -699,17 +699,6 @@ static result_t readConfigFiles(const string path, const string extension, Messa return RESULT_OK; }; -/** - * Helper method for logging loading of a configuration file. - * @param messages the @a MessageMap instance. - * @param address the address for which the file was loaded. - * @param file the name of the loaded file. - */ -void logFileLoaded(MessageMap* messages, const unsigned char address, string file) -{ - messages->addLoadedFile(address, file); -} - /** * Helper method for immediate reading of a @a Message from the bus. * @param message the @a Message to read. @@ -738,7 +727,7 @@ void executeInstructions(MessageMap* messages, bool verbose) logError(lf_main, "error resolving conditions: %s, %s", getResultCode(result), messages->getLastError().c_str()); } ostringstream log; - result = messages->executeInstructions(log, logFileLoaded, readMessage); + result = messages->executeInstructions(log, readMessage); if (result != RESULT_OK) { logError(lf_main, "error executing instructions: %s, %s, %s", getResultCode(result), messages->getLastError().c_str(), log.str().c_str()); } else if (verbose && log.tellp() > 0) { diff --git a/src/lib/ebus/message.cpp b/src/lib/ebus/message.cpp index f0bc3953..8ff97633 100644 --- a/src/lib/ebus/message.cpp +++ b/src/lib/ebus/message.cpp @@ -1399,7 +1399,7 @@ string Instruction::getDestination() } -result_t LoadInstruction::execute(MessageMap* messages, ostringstream& log, void (*loadInfoFunc)(MessageMap* messages, const unsigned char address, string filename)) { +result_t LoadInstruction::execute(MessageMap* messages, ostringstream& log) { result_t result = messages->readFromFile(m_filename, false, m_defaultDest, m_defaultCircuit, m_defaultSuffix); if (log.tellp()>0) { log << ", "; @@ -1409,7 +1409,7 @@ result_t LoadInstruction::execute(MessageMap* messages, ostringstream& log, void return result; } log << (isSingleton() ? "loaded " : "included ") << m_filename << " for \"" << getDestination() << "\""; - if (isSingleton() && loadInfoFunc!=NULL && !m_defaultDest.empty()) { + if (isSingleton() && !m_defaultDest.empty()) { result_t temp; unsigned char address = (unsigned char)parseInt(m_defaultDest.c_str(), 16, 0, 0xff, temp); if (temp==RESULT_OK) { @@ -1420,7 +1420,7 @@ result_t LoadInstruction::execute(MessageMap* messages, ostringstream& log, void } else { filename = m_filename.substr(pos+1); } - (*loadInfoFunc)(messages, address, filename); + messages->addLoadedFile(address, filename); } } return result; @@ -1696,7 +1696,7 @@ result_t MessageMap::resolveCondition(Condition* condition, void (*readMessageFu return result; } -result_t MessageMap::executeInstructions(ostringstream& log, void (*loadInfoFunc)(MessageMap* messages, const unsigned char address, string file), void (*readMessageFunc)(Message* message)) +result_t MessageMap::executeInstructions(ostringstream& log, void (*readMessageFunc)(Message* message)) { m_lastError = ""; result_t overallResult = RESULT_OK; @@ -1725,7 +1725,7 @@ result_t MessageMap::executeInstructions(ostringstream& log, void (*loadInfoFunc if (instruction->isSingleton()) { removeSingletons = true; } - result_t result = instruction->execute(this, log, loadInfoFunc); + result_t result = instruction->execute(this, log); if (result!=RESULT_OK) { overallResult = result; } diff --git a/src/lib/ebus/message.h b/src/lib/ebus/message.h index 207f9e20..8b90aac9 100644 --- a/src/lib/ebus/message.h +++ b/src/lib/ebus/message.h @@ -1010,10 +1010,9 @@ public: * Execute the instruction. * @param messages the @a MessageMap. * @param log the @a ostringstream to log success messages to (if necessary). - * @param loadInfoFunc the function to call for successful loading of a file for a certain address, or NULL. * @return @a RESULT_OK on success, or an error code. */ - virtual result_t execute(MessageMap* messages, ostringstream& log, void (*loadInfoFunc)(MessageMap* messages, const unsigned char address, string filename)=NULL) = 0; + virtual result_t execute(MessageMap* messages, ostringstream& log) = 0; private: @@ -1062,7 +1061,7 @@ public: virtual ~LoadInstruction() { } // @copydoc - virtual result_t execute(MessageMap* messages, ostringstream& log, void (*loadInfoFunc)(MessageMap* messages, const unsigned char address, string filename)=NULL); + virtual result_t execute(MessageMap* messages, ostringstream& log); private: @@ -1150,12 +1149,11 @@ public: /** * Run all executable @a Instruction instances. * @param log the @a ostringstream to log success messages to (if necessary). - * @param loadInfoFunc the function to call for successful loading of a file for a participant, or NULL. * @param readMessageFunc the function to call for immediate reading of a * @a Message values from the bus required for singleton instructions, or NULL. * @return @a RESULT_OK on success, or an error code. */ - result_t executeInstructions(ostringstream& log, void (*loadInfoFunc)(MessageMap* messages, const unsigned char address, string file)=NULL, void (*readMessageFunc)(Message* message)=NULL); + result_t executeInstructions(ostringstream& log, void (*readMessageFunc)(Message* message)=NULL); /** * Add a loaded file to a participant.