removed extra function call overhead again

This commit is contained in:
john30
2016-11-19 12:24:25 +01:00
parent f10217a368
commit ba2cfd157b
3 changed files with 9 additions and 22 deletions
+1 -12
View File
@@ -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) {
+5 -5
View File
@@ -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;
}
+3 -5
View File
@@ -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.