poke-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[COMMITTED] ios: avoid uneeded slow seeks


From: Jose E. Marchesi
Subject: [COMMITTED] ios: avoid uneeded slow seeks
Date: Sun, 05 Jun 2022 14:34:28 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)


2022-06-05  apache2  <apache2@ageinghacker.net>

        * libpoke/ios-dev-file.c (ios_dev_file_pread): Avoid slow unneeded
        seeks.,
---
 ChangeLog              | 5 +++++
 libpoke/ios-dev-file.c | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 345e71d3..b2ff3fd8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2022-06-05  apache2  <apache2@ageinghacker.net>
+
+       * libpoke/ios-dev-file.c (ios_dev_file_pread): Avoid slow unneeded
+       seeks.,
+
 2022-05-05  Jose E. Marchesi  <jemarch@gnu.org>
 
        * libpoke/pkl-gen.pks (struct_mapper): Add an explicative message
diff --git a/libpoke/ios-dev-file.c b/libpoke/ios-dev-file.c
index 66b451a6..625d0273 100644
--- a/libpoke/ios-dev-file.c
+++ b/libpoke/ios-dev-file.c
@@ -230,8 +230,9 @@ ios_dev_file_pread (void *iod, void *buf, size_t count, 
ios_dev_off offset)
 
   /* We are using FILE* for buffering, rather than low-level fd, so we
      have to fake low-level pread by using fseeko.  */
-  if (fseeko (fio->file, offset, SEEK_SET) == -1)
-    return IOD_EOF;
+  if (ftello(fio->file) != offset)
+    if (fseeko (fio->file, offset, SEEK_SET) == -1)
+      return IOD_EOF;
   ret = fread (buf, 1, count, fio->file);
 
   if (ferror (fio->file))
-- 
2.11.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]