diff options
author | Joshua Haberman <joshua@reverberate.org> | 2009-07-29 20:37:32 -0700 |
---|---|---|
committer | Joshua Haberman <joshua@reverberate.org> | 2009-07-29 20:37:32 -0700 |
commit | 4240e0e5989fadd367c29651e0a0b01d499927b0 (patch) | |
tree | bbcd5db02000e662e040725600c9674e37e4d667 /src/upb_string.h | |
parent | 5fa6912da86d8f264a23c9545c1a877a31603a49 (diff) |
Updated parser semantics to better support streaming.
Diffstat (limited to 'src/upb_string.h')
-rw-r--r-- | src/upb_string.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/upb_string.h b/src/upb_string.h index 8e56daa..528c8c8 100644 --- a/src/upb_string.h +++ b/src/upb_string.h @@ -37,6 +37,8 @@ extern "C" { #define INLINE static inline #endif +#define UPB_MIN(x, y) ((x) < (y) ? (x) : (y)) + struct upb_string { /* We expect the data to be 8-bit clean (uint8_t), but char* is such an * ingrained convention that we follow it. */ @@ -44,15 +46,13 @@ struct upb_string { uint32_t byte_len; }; -INLINE uint32_t min(uint32_t a, uint32_t b) { return a < b ? a : b; } - INLINE bool upb_streql(struct upb_string *s1, struct upb_string *s2) { return s1->byte_len == s2->byte_len && memcmp(s1->ptr, s2->ptr, s1->byte_len) == 0; } INLINE int upb_strcmp(struct upb_string s1, struct upb_string s2) { - size_t common_length = min(s1.byte_len, s2.byte_len); + size_t common_length = UPB_MIN(s1.byte_len, s2.byte_len); int common_diff = memcmp(s1.ptr, s2.ptr, common_length); if(common_diff == 0) return s1.byte_len - s2.byte_len; else return common_diff; |