Optimize struct initialization and accessors for the common case.
authorLudovic Courtès <ludo@gnu.org>
Sat, 23 Jan 2010 15:21:13 +0000 (16:21 +0100)
committerLudovic Courtès <ludo@gnu.org>
Sat, 23 Jan 2010 15:21:13 +0000 (16:21 +0100)
commitaa42c03669df8acf997d3108f08ce94d5d7611c2
tree095caa206925dd04fb17e7a6fb9e2ee54dace271
parent0e64cbea3d22411564af302a63b670fe0617ccf3
Optimize struct initialization and accessors for the common case.

* libguile/struct.c (set_vtable_layout_flags): New function.
  (scm_i_struct_inherit_vtable_magic): Use it.
  (scm_struct_init): Optimize the case where HANDLE's vtable has the
  `SCM_VTABLE_FLAG_SIMPLE' flag.
  (scm_struct_ref): Likewise.
  (scm_struct_ref): Likewise, when `SCM_VTABLE_FLAG_SIMPLE_RW' is also set.

* libguile/struct.h (SCM_VTABLE_BASE_LAYOUT): Update comment for the
  next-to-last hidden field.
  (scm_vtable_index_reserved_6): Rename to...
  (scm_vtable_index_size): ... this.
  (SCM_VTABLE_FLAG_RESERVED_0): Rename to...
  (SCM_VTABLE_FLAG_SIMPLE): ... this.
  (SCM_VTABLE_FLAG_RESERVED_1): Rename to...
  (SCM_VTABLE_FLAG_SIMPLE_RW): ... this.

* test-suite/tests/structs.test ("low-level struct
  procedures")["struct-ref", "struct-set!", "struct-ref out-of-range",
  "struct-set! out-of-range"]: New tests.
libguile/struct.c
libguile/struct.h
test-suite/tests/structs.test