shithub: freetype+ttf2subf

Download patch

ref: efaf5abcf8e18833e426a3718fe372ffa9249e57
parent: 2b6a3f0be9cebf4881710f1d238bdb062f19f548
author: Su Yu <[email protected]>
date: Mon Aug 3 15:55:58 EDT 2009

Don't call `ft_fseek' every time when executing `ft_fread'.

* src/base/ftstream.c (FT_Stream_Seek), src/base/ftsystem.c
(ft_ansi_stream_io): Implement it.

git/fs: mount .git/fs: mount/attach disallowed
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2009-08-03  [email protected]
+
+	Don't call `ft_fseek' every time when executing `ft_fread'.
+
+	* src/base/ftstream.c (FT_Stream_Seek), src/base/ftsystem.c
+	(ft_ansi_stream_io): Implement it.
+
 2009-07-31  suzuki toshiya <[email protected]>
 
 	sfnt: Cast a charcode to 32-bit in cmap format 14 parser.
--- a/src/base/ftstream.c
+++ b/src/base/ftstream.c
@@ -60,8 +60,6 @@
     FT_Error  error = FT_Err_Ok;
 
 
-    stream->pos = pos;
-
     if ( stream->read )
     {
       if ( stream->read( stream, pos, 0, 0 ) )
@@ -82,6 +80,9 @@
 
       error = FT_Err_Invalid_Stream_Operation;
     }
+
+    if ( !error )
+      stream->pos = pos;
 
     return error;
   }
--- a/src/base/ftsystem.c
+++ b/src/base/ftsystem.c
@@ -4,7 +4,7 @@
 /*                                                                         */
 /*    ANSI-specific FreeType low-level system interface (body).            */
 /*                                                                         */
-/*  Copyright 1996-2001, 2002, 2006, 2008 by                               */
+/*  Copyright 1996-2001, 2002, 2006, 2008, 2009 by                         */
 /*  David Turner, Robert Wilhelm, and Werner Lemberg.                      */
 /*                                                                         */
 /*  This file is part of the FreeType project, and may only be used,       */
@@ -205,7 +205,8 @@
 
     file = STREAM_FILE( stream );
 
-    ft_fseek( file, offset, SEEK_SET );
+    if ( stream->pos != offset )
+      ft_fseek( file, offset, SEEK_SET );
 
     return (unsigned long)ft_fread( buffer, 1, count, file );
   }