From ff2717e8c6a7633bbd38be95b2d30615802b6679 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 28 Dec 2015 11:41:04 +0100 Subject: apt-helper: Use CopyFile() for concatenating the files There's no point in keeping using yet another read-then-write loop. Gbp-Dch: ignore --- cmdline/apt-helper.cc | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'cmdline') diff --git a/cmdline/apt-helper.cc b/cmdline/apt-helper.cc index a519f3042..5e0b00c46 100644 --- a/cmdline/apt-helper.cc +++ b/cmdline/apt-helper.cc @@ -111,8 +111,6 @@ static bool DoCatFile(CommandLine &CmdL) /*{{{*/ { FileFd fd; FileFd out; - char buf[4096]; - unsigned long long read; if (out.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly) == false) return false; @@ -127,14 +125,8 @@ static bool DoCatFile(CommandLine &CmdL) /*{{{*/ if (fd.Open(name, FileFd::ReadOnly, FileFd::Extension) == 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; } -- cgit v1.2.3