[segyio] 222/376: Don't check seek errors in mmap-case loop

Jørgen Kvalsvik jokva-guest at moszumanska.debian.org
Wed Sep 20 08:04:36 UTC 2017


This is an automated email from the git hooks/post-receive script.

jokva-guest pushed a commit to branch debian
in repository segyio.

commit 121c8622ae82ac21b490045ad131826656307260
Author: Jørgen Kvalsvik <jokva at statoil.com>
Date:   Wed Mar 1 11:48:11 2017 +0100

    Don't check seek errors in mmap-case loop
    
    segy_seek when the file is mmap'd is a pointer bump, and it's only
    necessary to check for seek errors for the first/last trace. If both
    these are fine then all traces between them are obviously fine, and we
    don't need to check the error code.
---
 lib/src/segy.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/lib/src/segy.c b/lib/src/segy.c
index 5b82640..7f7c097 100644
--- a/lib/src/segy.c
+++ b/lib/src/segy.c
@@ -557,12 +557,18 @@ int segy_field_forall( segy_file* fp,
 
     int slicelen = slicelength( start, stop, step );
 
+    // check *once* that we don't look past the end-of-file
+    // checking seek error inside the loop is a performance killer
+    err = segy_seek( fp, start, trace0, trace_bsize );
+    if( err != SEGY_OK ) return err;
+    const int end = start + step * (slicelen - 1);
+    err = segy_seek( fp, end, trace0, trace_bsize );
+    if( err != SEGY_OK ) return err;
+
     if( fp->addr ) {
         for( int i = start; slicelen > 0; i += step, ++buf, --slicelen ) {
-            err = segy_seek( fp, i, trace0, trace_bsize );
-            if( err != 0 ) return SEGY_FSEEK_ERROR;
-
-            segy_get_field( fp->cur, field, &f );
+            segy_seek( fp, i, trace0, trace_bsize );
+            get_field( fp->cur, field_size, field, &f );
             *buf = f;
         }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/segyio.git



More information about the debian-science-commits mailing list