mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 11:50:28 +02:00
Recognize structs with both "pr" and "pw" flags as simple.
* libguile/struct.c (set_vtable_layout_flags): Keep the `SCM_VTABLE_FLAG_SIMPLE' flag when VTABLE has a mixture of `r' and `w' fields. * libguile/struct.h (SCM_VTABLE_FLAG_SIMPLE): Adjust comment.
This commit is contained in:
parent
bb190ddbba
commit
e03b7f73e2
2 changed files with 6 additions and 13 deletions
|
@ -180,18 +180,13 @@ set_vtable_layout_flags (SCM vtable)
|
||||||
{
|
{
|
||||||
case 'w':
|
case 'w':
|
||||||
case 'W':
|
case 'W':
|
||||||
if (!(flags & SCM_VTABLE_FLAG_SIMPLE_RW) && field > 0)
|
if (field == 0)
|
||||||
/* There's a mixture of `w' and `r' flags. */
|
|
||||||
flags = 0;
|
|
||||||
else
|
|
||||||
flags |= SCM_VTABLE_FLAG_SIMPLE_RW;
|
flags |= SCM_VTABLE_FLAG_SIMPLE_RW;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
case 'R':
|
case 'R':
|
||||||
if (flags & SCM_VTABLE_FLAG_SIMPLE_RW)
|
flags &= ~SCM_VTABLE_FLAG_SIMPLE_RW;
|
||||||
/* There's a mixture of `w' and `r' flags. */
|
|
||||||
flags = 0;
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -711,10 +706,8 @@ SCM_DEFINE (scm_struct_ref, "struct-ref", 2, 0, 0,
|
||||||
|
|
||||||
if (SCM_LIKELY (SCM_VTABLE_FLAG_IS_SET (vtable, SCM_VTABLE_FLAG_SIMPLE)
|
if (SCM_LIKELY (SCM_VTABLE_FLAG_IS_SET (vtable, SCM_VTABLE_FLAG_SIMPLE)
|
||||||
&& p < SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size)))
|
&& p < SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size)))
|
||||||
{
|
/* The fast path: HANDLE is a struct with only "p" fields. */
|
||||||
/* The fast path: HANDLE is a struct with only "p" fields. */
|
answer = SCM_PACK (data[p]);
|
||||||
answer = SCM_PACK (data[p]);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SCM layout;
|
SCM layout;
|
||||||
|
@ -801,7 +794,7 @@ SCM_DEFINE (scm_struct_set_x, "struct-set!", 3, 0, 0,
|
||||||
if (SCM_LIKELY (SCM_VTABLE_FLAG_IS_SET (vtable, SCM_VTABLE_FLAG_SIMPLE)
|
if (SCM_LIKELY (SCM_VTABLE_FLAG_IS_SET (vtable, SCM_VTABLE_FLAG_SIMPLE)
|
||||||
&& SCM_VTABLE_FLAG_IS_SET (vtable, SCM_VTABLE_FLAG_SIMPLE_RW)
|
&& SCM_VTABLE_FLAG_IS_SET (vtable, SCM_VTABLE_FLAG_SIMPLE_RW)
|
||||||
&& p < SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size)))
|
&& p < SCM_STRUCT_DATA_REF (vtable, scm_vtable_index_size)))
|
||||||
/* The fast path: HANDLE is a struct with only "p" fields. */
|
/* The fast path: HANDLE is a struct with only "pw" fields. */
|
||||||
data[p] = SCM_UNPACK (val);
|
data[p] = SCM_UNPACK (val);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,7 +107,7 @@
|
||||||
#define SCM_VTABLE_FLAG_APPLICABLE (1L << 2) /* instances of this vtable are applicable? */
|
#define SCM_VTABLE_FLAG_APPLICABLE (1L << 2) /* instances of this vtable are applicable? */
|
||||||
#define SCM_VTABLE_FLAG_SETTER_VTABLE (1L << 3) /* instances of this vtable are applicable-with-setter vtables? */
|
#define SCM_VTABLE_FLAG_SETTER_VTABLE (1L << 3) /* instances of this vtable are applicable-with-setter vtables? */
|
||||||
#define SCM_VTABLE_FLAG_SETTER (1L << 4) /* instances of this vtable are applicable-with-setters? */
|
#define SCM_VTABLE_FLAG_SETTER (1L << 4) /* instances of this vtable are applicable-with-setters? */
|
||||||
#define SCM_VTABLE_FLAG_SIMPLE (1L << 5) /* instances of this vtable have only "pr" fields */
|
#define SCM_VTABLE_FLAG_SIMPLE (1L << 5) /* instances of this vtable have only "p" fields */
|
||||||
#define SCM_VTABLE_FLAG_SIMPLE_RW (1L << 6) /* instances of this vtable have only "pw" fields */
|
#define SCM_VTABLE_FLAG_SIMPLE_RW (1L << 6) /* instances of this vtable have only "pw" fields */
|
||||||
#define SCM_VTABLE_FLAG_SMOB_0 (1L << 7)
|
#define SCM_VTABLE_FLAG_SMOB_0 (1L << 7)
|
||||||
#define SCM_VTABLE_FLAG_GOOPS_0 (1L << 8)
|
#define SCM_VTABLE_FLAG_GOOPS_0 (1L << 8)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue