This is the mail archive of the
binutils-cvs@sourceware.org
mailing list for the binutils project.
[binutils-gdb] PR23282, Reinstate seek optimization
- From: Alan Modra <amodra at sourceware dot org>
- To: bfd-cvs at sourceware dot org
- Date: 14 Jun 2018 02:09:46 -0000
- Subject: [binutils-gdb] PR23282, Reinstate seek optimization
https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=ff91d2f0e20fc91b6b101a0b20cbd38ab2d7fb50
commit ff91d2f0e20fc91b6b101a0b20cbd38ab2d7fb50
Author: Alan Modra <amodra@gmail.com>
Date: Wed Jun 13 23:57:17 2018 +0930
PR23282, Reinstate seek optimization
PR 23282
* bfdio.c (bfd_seek): Optimize away seeks to current position.
Diff:
---
bfd/ChangeLog | 5 +++++
bfd/bfdio.c | 4 ++++
2 files changed, 9 insertions(+)
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 8b70682..d9465d5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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>
diff --git a/bfd/bfdio.c b/bfd/bfdio.c
index 136fa8b..1f4caca 100644
--- a/bfd/bfdio.c
+++ b/bfd/bfdio.c
@@ -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)
{