Просмотр исходного кода

apt-helper: Use CopyFile() for concatenating the files

There's no point in keeping using yet another read-then-write
loop.

Gbp-Dch: ignore
Julian Andres Klode лет назад: 10
Родитель
Сommit
ff2717e8c6
1 измененных файлов с 2 добавлено и 10 удалено
  1. 2 10
      cmdline/apt-helper.cc

+ 2 - 10
cmdline/apt-helper.cc

@@ -111,8 +111,6 @@ static bool DoCatFile(CommandLine &CmdL)				/*{{{*/
 {
 {
    FileFd fd;
    FileFd fd;
    FileFd out;
    FileFd out;
-   char buf[4096];
-   unsigned long long read;
 
 
    if (out.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly) == false)
    if (out.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly) == false)
       return false;
       return false;
@@ -127,14 +125,8 @@ static bool DoCatFile(CommandLine &CmdL)				/*{{{*/
       if (fd.Open(name, FileFd::ReadOnly, FileFd::Extension) == false)
       if (fd.Open(name, FileFd::ReadOnly, FileFd::Extension) == false)
          return false;
          return false;
 
 
-      for (;;) {
-         if (fd.Read(buf, sizeof(buf), &read) == false)
-            return false;
-         if (read == 0)
-            break;
-         if (out.Write(buf, read) == false)
-            return false;
-      }
+      if (CopyFile(fd, out) == false)
+         return false;
    }
    }
    return true;
    return true;
 }
 }