public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] make ar faster
@ 2023-04-27 23:35 Oleg Tolmatcev
  2023-05-03 15:27 ` Nick Clifton
  0 siblings, 1 reply; 3+ messages in thread
From: Oleg Tolmatcev @ 2023-04-27 23:35 UTC (permalink / raw)
  To: binutils

[-- Attachment #1: Type: text/plain, Size: 1149 bytes --]

Hello all,

this patch makes ar faster by increasing the buffer size from 8 KB to 8 MB.

---
 bfd/archive.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/bfd/archive.c b/bfd/archive.c
index 4cc2f7c9..d179bcd3 100644
--- a/bfd/archive.c
+++ b/bfd/archive.c
@@ -2209,11 +2209,14 @@ _bfd_write_archive_contents (bfd *arch)
     }
     }

+  char *buffer = bfd_malloc (DEFAULT_BUFFERSIZE * 1024);
+  if (buffer == NULL)
+    return false;
+
   for (current = arch->archive_head;
        current != NULL;
        current = current->archive_next)
     {
-      char buffer[DEFAULT_BUFFERSIZE];
       bfd_size_type remaining = arelt_size (current);

       /* Write ar header.  */
@@ -2226,7 +2229,7 @@ _bfd_write_archive_contents (bfd *arch)

       while (remaining)
     {
-      size_t amt = DEFAULT_BUFFERSIZE;
+      size_t amt = DEFAULT_BUFFERSIZE * 1024;

       if (amt > remaining)
         amt = remaining;
@@ -2245,6 +2248,8 @@ _bfd_write_archive_contents (bfd *arch)
     }
     }

+  free (buffer);
+
   if (makemap && hasobjects)
     {
       /* Verify the timestamp in the archive file.  If it would not be

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-05-03 18:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-04-27 23:35 [PATCH] make ar faster Oleg Tolmatcev
2023-05-03 15:27 ` Nick Clifton
2023-05-03 18:10   ` Oleg Tolmatcev

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).