1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-24 20:30:28 +02:00

bytevector inlinedness indicated by flag, not length

* libguile/bytevectors.h (SCM_BYTEVECTOR_INLINE_P): Change to check a
  flag instead of checking the length of the bytevector.

* libguile/bytevectors.c (make_bytevector_from_buffer): Handle the len
  <= inline threshold case as well. Set the inline flag as appropriate.
  (make_bytevector): Updat the inline flag as appropriate.
  (scm_c_take_bytevector): Just dispatch to make_bytevector_from_buffer.
  (scm_i_shrink_bytevector): Update the inline flag as appropriate.
  Update the length when shrinking an already-inlined vector.
  (STRING_TO_UTF): Fix some indentation.
This commit is contained in:
Andy Wingo 2009-07-18 13:46:29 +02:00
parent ac8ed3db31
commit f332089ed4
2 changed files with 41 additions and 39 deletions

View file

@ -116,13 +116,11 @@ SCM_API SCM scm_utf32_to_string (SCM, SCM);
i.e., without allocating memory beside the SMOB itself (a double cell).
This optimization is necessary since small bytevectors are expected to be
common. */
#define SCM_BYTEVECTOR_P(_bv) \
#define SCM_BYTEVECTOR_P(_bv) \
SCM_SMOB_PREDICATE (scm_tc16_bytevector, _bv)
#define SCM_BYTEVECTOR_INLINE_THRESHOLD (2 * sizeof (SCM))
#define SCM_BYTEVECTOR_INLINEABLE_SIZE_P(_size) \
((_size) <= SCM_BYTEVECTOR_INLINE_THRESHOLD)
#define SCM_BYTEVECTOR_INLINE_P(_bv) \
(SCM_BYTEVECTOR_INLINEABLE_SIZE_P (SCM_BYTEVECTOR_LENGTH (_bv)))
#define SCM_F_BYTEVECTOR_INLINE 0x1
#define SCM_BYTEVECTOR_INLINE_P(_bv) \
(SCM_SMOB_FLAGS (_bv) & SCM_F_BYTEVECTOR_INLINE)
/* Hint that is passed to `scm_gc_malloc ()' and friends. */
#define SCM_GC_BYTEVECTOR "bytevector"