]> granicus.if.org Git - icinga2/commitdiff
Minor performance tweaks.
authorGunnar Beutner <gunnar@beutner.name>
Wed, 27 Mar 2013 18:02:51 +0000 (18:02 +0000)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 27 Mar 2013 18:02:51 +0000 (18:02 +0000)
components/delegation/delegationcomponent.cpp
lib/base/process-unix.cpp

index bbf7df3916691a25fcf244f54b22a3e8a9240e74..a14371c62fd2080d4c802127746bda7b67612594 100644 (file)
@@ -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];
index f86ed700a176377b775983a09e7117a138f6861b..1b90a9eb611a348148c7514fb543d76606e48c73 100644 (file)
@@ -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();