PR23282, Reinstate seek optimization
authorAlan Modra <amodra@gmail.com>
Wed, 13 Jun 2018 14:27:17 +0000 (23:57 +0930)
committerAlan Modra <amodra@gmail.com>
Thu, 14 Jun 2018 02:02:01 +0000 (11:32 +0930)
PR 23282
* bfdio.c (bfd_seek): Optimize away seeks to current position.

bfd/ChangeLog
bfd/bfdio.c

index 8b706823194a082979af84f2e55103994bc0e792..d9465d5d84fd03eb364a9e17e90bc18c33e96a3d 100644 (file)
@@ -1,3 +1,8 @@
+2018-06-14  Alan Modra  <amodra@gmail.com>
+
+       PR 23282
+       * bfdio.c (bfd_seek): Optimize away seeks to current position.
+
 2018-06-13  Scott Egerton  <scott.egerton@imgtec.com>
            Faraz Shahbazker  <Faraz.Shahbazker@mips.com>
 
index 136fa8b1d3f0f43dddc6b76cb28efcdc19b9b25d..1f4caca4ed1a7321a3416aece61bc7beb2fdb264 100644 (file)
@@ -330,6 +330,10 @@ bfd_seek (bfd *abfd, file_ptr position, int direction)
   if (direction != SEEK_CUR)
     position += offset;
 
+  if ((direction == SEEK_CUR && position == 0)
+      || (direction == SEEK_SET && (ufile_ptr) position == abfd->where))
+    return 0;
+
   result = abfd->iovec->bseek (abfd, position, direction);
   if (result != 0)
     {
This page took 0.025136 seconds and 4 git commands to generate.