Explorar o código

Refactor InternalReadLine to not unroll Size == 0 case

There is not much point and this is more readable.

Gbp-Dch: ignore
Julian Andres Klode %!s(int64=10) %!d(string=hai) anos
pai
achega
01152444ba
Modificáronse 1 ficheiros con 4 adicións e 5 borrados
  1. 4 5
      apt-pkg/contrib/fileutl.cc

+ 4 - 5
apt-pkg/contrib/fileutl.cc

@@ -970,13 +970,12 @@ public:
    {
       if (unlikely(Size == 0))
 	 return nullptr;
+      // Read one byte less than buffer size to have space for trailing 0.
       --Size;
-      To[0] = '\0';
-      if (unlikely(Size == 0))
-	 return To;
+
       char * const InitialTo = To;
 
-      do {
+      while (Size > 0) {
 	 if (buffer.empty() == true)
 	 {
 	    buffer.reset();
@@ -1004,7 +1003,7 @@ public:
 	 Size -= actualread;
 	 if (newline != nullptr)
 	    break;
-      } while (Size > 0);
+      }
       *To = '\0';
       return InitialTo;
    }