diff options
author | Frank Dischner <phaedrus961@rockbox.org> | 2006-04-24 16:02:44 +0000 |
---|---|---|
committer | Frank Dischner <phaedrus961@rockbox.org> | 2006-04-24 16:02:44 +0000 |
commit | bf64c451488a0e73ceda1fe45d4e9d0230ef1201 (patch) | |
tree | 1bebeedafaf674c9fa29c899f438b97e0e8b2509 /firmware/font.c | |
parent | 38ae72ac1e219a01b9e98528e4da410bbef2c565 (diff) | |
download | rockbox-bf64c451488a0e73ceda1fe45d4e9d0230ef1201.tar.gz rockbox-bf64c451488a0e73ceda1fe45d4e9d0230ef1201.zip |
Use filesize instead of lseek to find the size of a file. Reduces disk access and improves font loading time.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@9792 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/font.c')
-rw-r--r-- | firmware/font.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/firmware/font.c b/firmware/font.c index 5f244bcb37..5eb6f7450f 100644 --- a/firmware/font.c +++ b/firmware/font.c @@ -283,7 +283,7 @@ struct font* font_load_cached(struct font* pf) /* read and load font into incore font structure*/ struct font* font_load(const char *path) { - int filesize; + int size; struct font* pf = &font_ui; /* save loaded glyphs */ @@ -302,8 +302,7 @@ struct font* font_load(const char *path) } /* Check file size */ - filesize = lseek(fnt_file, 0, SEEK_END); - lseek(fnt_file, 0, SEEK_SET); + size = filesize(fnt_file); font_reset(); @@ -312,7 +311,7 @@ struct font* font_load(const char *path) fileptr = freeptr; - if (filesize > MAX_FONT_SIZE) + if (size > MAX_FONT_SIZE) { read(fnt_file, fileptr, FONT_HEADER_SIZE); eofptr = fileptr + FONT_HEADER_SIZE; @@ -334,7 +333,7 @@ struct font* font_load(const char *path) else { read(fnt_file, fileptr, MAX_FONT_SIZE); - eofptr = fileptr + filesize; + eofptr = fileptr + size; close(fnt_file); fnt_file = -1; |