Inline CBS_init, CBS_data, and CBS_len These are very basic accessors and we'll never make CBS opaque. Just inline them so the compiler can optimize around them. Change-Id: I65442acb9a89a611082c7e0c82b365c78adae7f4 Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/66727 Auto-Submit: David Benjamin <davidben@google.com> Reviewed-by: Bob Beck <bbe@google.com> Commit-Queue: David Benjamin <davidben@google.com>
diff --git a/crypto/bytestring/cbs.c b/crypto/bytestring/cbs.c index 631f284..bf94db1 100644 --- a/crypto/bytestring/cbs.c +++ b/crypto/bytestring/cbs.c
@@ -26,11 +26,6 @@ #include "internal.h" -void CBS_init(CBS *cbs, const uint8_t *data, size_t len) { - cbs->data = data; - cbs->len = len; -} - static int cbs_get(CBS *cbs, const uint8_t **p, size_t n) { if (cbs->len < n) { return 0; @@ -47,14 +42,6 @@ return cbs_get(cbs, &dummy, len); } -const uint8_t *CBS_data(const CBS *cbs) { - return cbs->data; -} - -size_t CBS_len(const CBS *cbs) { - return cbs->len; -} - int CBS_stow(const CBS *cbs, uint8_t **out_ptr, size_t *out_len) { OPENSSL_free(*out_ptr); *out_ptr = NULL;
diff --git a/include/openssl/bytestring.h b/include/openssl/bytestring.h index 7dce9c4..0d48628 100644 --- a/include/openssl/bytestring.h +++ b/include/openssl/bytestring.h
@@ -58,17 +58,20 @@ // CBS_init sets |cbs| to point to |data|. It does not take ownership of // |data|. -OPENSSL_EXPORT void CBS_init(CBS *cbs, const uint8_t *data, size_t len); +OPENSSL_INLINE void CBS_init(CBS *cbs, const uint8_t *data, size_t len) { + cbs->data = data; + cbs->len = len; +} // CBS_skip advances |cbs| by |len| bytes. It returns one on success and zero // otherwise. OPENSSL_EXPORT int CBS_skip(CBS *cbs, size_t len); // CBS_data returns a pointer to the contents of |cbs|. -OPENSSL_EXPORT const uint8_t *CBS_data(const CBS *cbs); +OPENSSL_INLINE const uint8_t *CBS_data(const CBS *cbs) { return cbs->data; } // CBS_len returns the number of bytes remaining in |cbs|. -OPENSSL_EXPORT size_t CBS_len(const CBS *cbs); +OPENSSL_INLINE size_t CBS_len(const CBS *cbs) { return cbs->len; } // CBS_stow copies the current contents of |cbs| into |*out_ptr| and // |*out_len|. If |*out_ptr| is not NULL, the contents are freed with