[icinga-checkins] icinga.org: icinga2/master: Minor performance tweaks.

git at icinga.org git at icinga.org
Wed Mar 27 19:03:04 CET 2013


Module: icinga2
Branch: master
Commit: 2e051ad9e234e1ca8fcf7cc8479b47b6981ae8d0
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=2e051ad9e234e1ca8fcf7cc8479b47b6981ae8d0

Author: Gunnar Beutner <gunnar at beutner.name>
Date:   Wed Mar 27 18:02:51 2013 +0000

Minor performance tweaks.

---

 components/delegation/delegationcomponent.cpp |    2 ++
 lib/base/process-unix.cpp                     |   14 +++++++-------
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/components/delegation/delegationcomponent.cpp b/components/delegation/delegationcomponent.cpp
index bbf7df3..a14371c 100644
--- a/components/delegation/delegationcomponent.cpp
+++ b/components/delegation/delegationcomponent.cpp
@@ -127,9 +127,11 @@ void DelegationComponent::DelegationTimerHandler(void)
 		std::vector<Endpoint::Ptr>::iterator cit;
 
 		if (!candidates.empty()) {
+#ifdef _DEBUG
 			std::ostringstream msgbuf;
 			msgbuf << "Service: " << service->GetName() << ", candidates: " << candidates.size();
 			Log(LogDebug, "delegation", msgbuf.str());
+#endif /* _DEBUG */
 
 			BOOST_FOREACH(const Endpoint::Ptr& candidate, candidates) {
 				avg_services += histogram[candidate];
diff --git a/lib/base/process-unix.cpp b/lib/base/process-unix.cpp
index f86ed70..1b90a9e 100644
--- a/lib/base/process-unix.cpp
+++ b/lib/base/process-unix.cpp
@@ -155,17 +155,17 @@ ProcessResult Process::Run(void)
 	(void) close(fds[1]);
 
 		char buffer[512];
-	int rc;
 
 	std::ostringstream outputStream;
 
-	do {
-		rc = read(fd, buffer, sizeof(buffer));
+	for (;;) {
+		int rc = read(fd, buffer, sizeof(buffer));
 
-		if (rc > 0) {
-			outputStream.write(buffer, rc);
-		}
-	} while (rc > 0);
+		if (rc <= 0)
+			break;
+
+		outputStream.write(buffer, rc);
+	}
 
 	String output = outputStream.str();
 





More information about the icinga-checkins mailing list