Implemented inlined bytevectors.
commit8a3b145aab700c35dc6475062ea70fb949b4fc11
authorLudovic Courtes <ludovic.courtes@laas.fr>
Sun, 25 Feb 2007 15:40:53 +0000 (25 15:40 +0000)
committerLudovic Courtes <ludovic.courtes@laas.fr>
Sun, 25 Feb 2007 15:40:53 +0000 (25 15:40 +0000)
treec1fc00751d6c12c9add5ba318a8f11a13dbc5df9
parent70c1143ff39ee492a8dd981a1e1874b07b77ab0e
Implemented inlined bytevectors.

* src/bytevector.c (SCM_R6RS_BYTEVECTOR_SET_LENGTH,
  SCM_R6RS_BYTEVECTOR_SET_CONTENTS): New macros.
  (scm_r6rs_null_bytevector): New.
  (make_bytevector_from_buffer): New.
  (make_bytevector): Check whether LEN is inlineable and only allocate
  when non-inlineable.  Don't take a CONTENTS argument: allocate space here.
  (scm_r6rs_c_make_bytevector): Updated.
  (scm_r6rs_c_take_bytevector): Check whether LEN is inlineable.
  (scm_r6rs_i_shrink_bytevector): New.
  (free_bytevector): Only free when BV is in-line.
  (scm_r6rs_make_bytevector): Updated.
  (scm_r6rs_bytevector_copy): Likewise.
  (scm_r6rs_u8_list_to_bytevector): Likewise.
  (INTEGER_LIST_TO_BYTEVECTOR): Likewise.
  (scm_init_r6rs_bytevector): Initialize SCM_R6RS_NULL_BYTEVECTOR.

* src/bytevector.h (SCM_R6RS_BYTEVECTOR_CONTENTS): Check whether BV is
  inline and return the appropriate pointer.
  (SCM_R6RS_BYTEVECTOR_INLINE_THRESHOLD,
  SCM_R6RS_BYTEVECTOR_INLINEABLE_SIZE_P, SCM_R6RS_BYTEVECTOR_INLINE_P):
  New macros.
  (scm_r6rs_c_shrink_bytevector): New macro.
  (scm_r6rs_i_shrink_bytevector, scm_r6rs_null_bytevector): New
  declarations.

* src/ports.c (scm_r6rs_get_bytevector_n): Use
  `scm_r6rs_c_make_bytevector ()' instead of custom memory management.
  At the end, use `scm_r6rs_c_shrink_bytevector ()'.

git-archimport-id: lcourtes@laas.fr--2006-libre/guile-r6rs-libs--devo--0--patch-30
ChangeLog
src/bytevector.c
src/bytevector.h
src/ports.c