Date: Tuesday, January 30, 2007 @ 15:32:27
  Author: marc
    Path: /cvsroot/carob/carob/src

Modified: BufferedSocket.cpp (1.5 -> 1.6)

Simplified toBeReadThisTime = min (remainingBytesToRead, availableBytes). 
CAROB-123


--------------------+
 BufferedSocket.cpp |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)


Index: carob/src/BufferedSocket.cpp
diff -u carob/src/BufferedSocket.cpp:1.5 carob/src/BufferedSocket.cpp:1.6
--- carob/src/BufferedSocket.cpp:1.5    Tue Jan 30 15:14:31 2007
+++ carob/src/BufferedSocket.cpp        Tue Jan 30 15:32:27 2007
@@ -16,7 +16,7 @@
  * limitations under the License.
  *
  * Initial developer(s): Gilles Rayrat
- * Contributor(s):
+ * Contributor(s): Marc Herbert
  */
 
 #include "BufferedSocket.hpp"
@@ -63,16 +63,13 @@
 
       availableBytes = fillReadBuffer(flags);
     }
-    
-    // be optimistic and assume we have enough in stock...
-    int toBeReadThisTime = remainingBytesToRead;
 
-    // ... unless proven wrong
-    if (remainingBytesToRead > availableBytes)
-    {
-      // not enough data ready, just give those available and loop
-      toBeReadThisTime = availableBytes;
-    }
+    // toBeReadThisTime = min (remainingBytesToRead, availableBytes)
+    int toBeReadThisTime =
+      remainingBytesToRead < availableBytes
+      ? remainingBytesToRead // we have enough in stock.
+      : availableBytes;      // not enough: copy all what we already have and 
loop
+
     memcpy(static_cast<java_byte*>(static_cast<java_byte*>(buf)+alreadyRead),
            read_cache.getData(),
            toBeReadThisTime);

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

Reply via email to