Date: Thursday, January 25, 2007 @ 16:30:47
  Author: marc
    Path: /cvsroot/carob/carob

Modified: include/JavaSocket.hpp (1.42 -> 1.43) src/JavaSocket.cpp (1.79
          -> 1.80)

Pushed previous optimization further down the stack so we don't
instantiate a new wstring object at each receiveFromSocket() and
sendToSocket() function entry but only when logging. Note that those
methods are in the critical path.


------------------------+
 include/JavaSocket.hpp |    6 +++---
 src/JavaSocket.cpp     |   14 +++++++-------
 2 files changed, 10 insertions(+), 10 deletions(-)


Index: carob/include/JavaSocket.hpp
diff -u carob/include/JavaSocket.hpp:1.42 carob/include/JavaSocket.hpp:1.43
--- carob/include/JavaSocket.hpp:1.42   Fri Jan 19 13:04:31 2007
+++ carob/include/JavaSocket.hpp        Thu Jan 25 16:30:47 2007
@@ -208,7 +208,7 @@
    * @param flags send option, see recv man page
    * @throws SocketIOException
    */
-  void          sendToSocket(const std::wstring& fctName,
+  void          sendToSocket(const wchar_t fctName[],
                     const std::wstring& objName, const void* buf, int len,
                     int flags) const throw (SocketIOException,
                     UnexpectedException);
@@ -221,7 +221,7 @@
    * @param flags send option, see send man page
    * @throws SocketIOException in case of error
    */
-  void          receiveFromSocket(const std::wstring& fctName,
+  void          receiveFromSocket(const wchar_t fctName[],
                     const std::wstring& objName, 
                     void *buf, int len, int flags)
                     const throw (SocketIOException, UnexpectedException);
@@ -243,7 +243,7 @@
    * @param blocking true to set to blocking mode, false to non-blocking
    * @throw ConnectionException if the operation fails
    */
-  void          setBlockingMode(const std::wstring& fctName, bool blocking)
+  void          setBlockingMode(const wchar_t fctName[], bool blocking)
                     throw (ConnectionException, UnexpectedException);
 
 };
Index: carob/src/JavaSocket.cpp
diff -u carob/src/JavaSocket.cpp:1.79 carob/src/JavaSocket.cpp:1.80
--- carob/src/JavaSocket.cpp:1.79       Thu Jan 25 16:10:52 2007
+++ carob/src/JavaSocket.cpp    Thu Jan 25 16:30:47 2007
@@ -575,7 +575,7 @@
   return alreadyRead;
 }
 
-void JavaSocket::sendToSocket(const wstring& fctName, const wstring& objName,
+void JavaSocket::sendToSocket(const wchar_t fctName[], const wstring& objName,
     const void* buf, int len, int flags) const
     throw (SocketIOException, UnexpectedException)
 {
@@ -584,19 +584,19 @@
   int ret = send(socket_fd, static_cast<const char*>(buf), len, flags);
   if ( ret == -1 )
   {
-    throw SocketIOException(L'(' + fctName + L"): could not write "
+    throw SocketIOException(std::wstring(L"(") + fctName + L"): could not 
write "
         + objName + L" to socket");
   }
   if (ret != len)
   {
     // should never happen
-    throw SocketIOException(L'(' + fctName + L"): only " + toUserString(ret)
+    throw SocketIOException(std::wstring(L"(") + fctName + L"): only " + 
toUserString(ret)
         + L"/" + toUserString(len) + L" bytes send while sending " + objName
         + L" to socket");
   }
 }
 
-void JavaSocket::receiveFromSocket(const wstring& fctName,
+void JavaSocket::receiveFromSocket(const wchar_t fctName[],
     const wstring& objName, void *buf, int len, int flags) const
     throw (SocketIOException, UnexpectedException)
 {
@@ -606,17 +606,17 @@
   int status = recvFully(buf, len, flags);
 
   if (status == -1)
-    throw SocketIOException(fctName + L"Could not read from socket.");
+    throw SocketIOException(std::wstring(fctName) + L"Could not read from 
socket.");
 
   if (status == 0)
-    throw SocketIOException(fctName + L"Peer reset connection while 
receiving");
+    throw SocketIOException(std::wstring(fctName) + L"Peer reset connection 
while receiving");
 
   // else it went fine
   // if (status != len)
   //  throw SocketIOException(fctName + L"something is really wrong!");
 }
 
-void JavaSocket::setBlockingMode(const wstring& fctName, bool blocking)
+void JavaSocket::setBlockingMode(const wchar_t fctName[], bool blocking)
     throw (ConnectionException, UnexpectedException)
 {
   long fcntlopt = fcntl(socket_fd, F_GETFL, NULL);

_______________________________________________
Carob-commits mailing list
[email protected]
https://forge.continuent.org/mailman/listinfo/carob-commits

Reply via email to