Skip to content

Commit ee49a5e

Browse files
committed
Speed up cimg::fsize
1 parent 2ed5db5 commit ee49a5e

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

CImg.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67567,13 +67567,11 @@ namespace cimg_library {
6756767567
#if cimg_OS==1 // Optimized for POSIX Environements (Linux, macOS, BSD, etc.)
6756867568
const int fd = fileno(file);
6756967569
struct stat st;
67570-
if (fd>=0 && !fstat(fd,&st)) return (cimg_int64)st.st_size;
67570+
if (!fstat(fd,&st)) return (cimg_int64)st.st_size;
6757167571
#elif cimg_OS==2 // Optimized for Windows Environements (MSVC, MinGW)
6757267572
const int fd = _fileno(file);
67573-
if (fd>=0) {
67574-
const cimg_int64 siz = (cimg_int64)_filelengthi64(fd);
67575-
if (siz>=0) return siz;
67576-
}
67573+
const cimg_int64 siz = (cimg_int64)_filelengthi64(fd);
67574+
if (siz>=0) return siz;
6757767575
#endif
6757867576
// Fallback, used for non-POSIX systems or if fstat failed (pipes or sockets).
6757967577
const cimg_long pos = cimg::ftell(file);

0 commit comments

Comments
 (0)