Add compile-time option PB_BUFFER_ONLY.

This allows slight optimizations if only memory buffer support
(as opposed to stream callbacks) is wanted. On ARM difference
is -12% execution time, -4% code size when enabled.
This commit is contained in:
Petteri Aimonen
2013-02-06 20:54:25 +02:00
parent 39b8a5e2bb
commit 4ba6a3027d
6 changed files with 60 additions and 3 deletions

View File

@@ -32,7 +32,16 @@ extern "C" {
*/
struct _pb_istream_t
{
#ifdef PB_BUFFER_ONLY
/* Callback pointer is not used in buffer-only configuration.
* Having an int pointer here allows binary compatibility but
* gives an error if someone tries to assign callback function.
*/
int *callback;
#else
bool (*callback)(pb_istream_t *stream, uint8_t *buf, size_t count);
#endif
void *state; /* Free field for use by callback implementation */
size_t bytes_left;