mirror of
https://github.com/amadvance/snapraid.git
synced 2026-11-20 23:16:28 -05:00
Inline buffered reads and use memcpy for the fast path
This commit is contained in:
parent
29c1da9589
commit
4e1c073a24
2 changed files with 26 additions and 23 deletions
|
|
@ -245,11 +245,26 @@ static inline void sungetc(int c, STREAM* s)
|
|||
--s->pos;
|
||||
}
|
||||
|
||||
/**
|
||||
* \internal Used by sread() when the requested data crosses the buffered range.
|
||||
* \note Don't call this directly, but use sread().
|
||||
*/
|
||||
int sread_uncached(STREAM* f, void* void_data, size_t size);
|
||||
|
||||
/**
|
||||
* Read a fixed amount of chars.
|
||||
* Return 0 on success, or -1 on error.
|
||||
*/
|
||||
int sread(STREAM* f, void* void_data, size_t size);
|
||||
static inline int sread(STREAM* f, void* void_data, size_t size)
|
||||
{
|
||||
if (tommy_unlikely(!sptrlookup(f, size)))
|
||||
return sread_uncached(f, void_data, size);
|
||||
|
||||
memcpy(void_data, f->pos, size);
|
||||
f->pos += size;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a char from a stream, ignoring one '\r'.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue