[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Guile-commits] 07/21: Embed scm_t_port in scm_t_port_internal
From: |
Andy Wingo |
Subject: |
[Guile-commits] 07/21: Embed scm_t_port in scm_t_port_internal |
Date: |
Mon, 16 May 2016 07:39:34 +0000 (UTC) |
wingo pushed a commit to branch wip-port-refactor
in repository guile.
commit 209d50c7d8c1f8e5e365eb7d88d53c297d71621e
Author: Andy Wingo <address@hidden>
Date: Fri May 13 10:24:32 2016 +0200
Embed scm_t_port in scm_t_port_internal
* libguile/ports-internal.h (scm_t_port_internal)
* libguile/ports.h (scm_t_port): Embed scm_t_port in scm_t_port_internal
so that we have just one allocation.
* libguile/ports-internal.h (SCM_PORT_GET_INTERNAL): Adapt.
* libguile/ports.c (scm_i_port_property, scm_i_set_port_property_x)
(scm_c_make_port_with_encoding): Adapt.
---
libguile/ports-internal.h | 3 ++-
libguile/ports.c | 17 +++++------------
libguile/ports.h | 3 ---
3 files changed, 7 insertions(+), 16 deletions(-)
diff --git a/libguile/ports-internal.h b/libguile/ports-internal.h
index 689e61c..a7d61d4 100644
--- a/libguile/ports-internal.h
+++ b/libguile/ports-internal.h
@@ -226,6 +226,7 @@ typedef struct scm_iconv_descriptors
scm_t_iconv_descriptors;
struct scm_port_internal
{
+ scm_t_port pt;
unsigned at_stream_start_for_bom_read : 1;
unsigned at_stream_start_for_bom_write : 1;
scm_t_iconv_descriptors *iconv_descriptors;
@@ -236,7 +237,7 @@ typedef struct scm_port_internal scm_t_port_internal;
#define SCM_UNICODE_BOM 0xFEFFUL /* Unicode byte-order mark */
-#define SCM_PORT_GET_INTERNAL(x) (SCM_PTAB_ENTRY(x)->internal)
+#define SCM_PORT_GET_INTERNAL(x) ((scm_t_port_internal*) SCM_PTAB_ENTRY(x))
typedef enum scm_t_port_rw_active {
SCM_PORT_NEITHER = 0,
diff --git a/libguile/ports.c b/libguile/ports.c
index 6003129..c3d5f5e 100644
--- a/libguile/ports.c
+++ b/libguile/ports.c
@@ -366,15 +366,9 @@ SCM_DEFINE (scm_i_port_property, "%port-property", 2, 0, 0,
"Return the property of @var{port} associated with @var{key}.")
#define FUNC_NAME s_scm_i_port_property
{
- SCM result;
- scm_t_port *pt;
-
SCM_VALIDATE_OPPORT (1, port);
- pt = SCM_PTAB_ENTRY (port);
- result = scm_assq_ref (pt->internal->alist, key);
-
- return result;
+ return scm_assq_ref (SCM_PORT_GET_INTERNAL (port)->alist, key);
}
#undef FUNC_NAME
@@ -383,12 +377,12 @@ SCM_DEFINE (scm_i_set_port_property_x,
"%set-port-property!", 3, 0, 0,
"Set the property of @var{port} associated with @var{key} to
@var{value}.")
#define FUNC_NAME s_scm_i_set_port_property_x
{
- scm_t_port *pt;
+ scm_t_port_internal *pti;
SCM_VALIDATE_OPPORT (1, port);
- pt = SCM_PTAB_ENTRY (port);
- pt->internal->alist = scm_assq_set_x (pt->internal->alist, key, value);
+ pti = SCM_PORT_GET_INTERNAL (port);
+ pti->alist = scm_assq_set_x (pti->alist, key, value);
return SCM_UNSPECIFIED;
}
@@ -725,15 +719,14 @@ scm_c_make_port_with_encoding (scm_t_bits tag, unsigned
long mode_bits,
scm_t_port_internal *pti;
scm_t_ptob_descriptor *ptob;
- entry = scm_gc_typed_calloc (scm_t_port);
pti = scm_gc_typed_calloc (scm_t_port_internal);
+ entry = &pti->pt;
ptob = scm_c_port_type_ref (SCM_TC2PTOBNUM (tag));
ret = scm_words (tag | mode_bits, 3);
SCM_SET_CELL_WORD_1 (ret, (scm_t_bits) entry);
SCM_SET_CELL_WORD_2 (ret, (scm_t_bits) ptob);
- entry->internal = pti;
entry->file_name = SCM_BOOL_F;
entry->stream = stream;
entry->encoding = encoding;
diff --git a/libguile/ports.h b/libguile/ports.h
index 84f4e01..793523b 100644
--- a/libguile/ports.h
+++ b/libguile/ports.h
@@ -81,9 +81,6 @@ enum scm_port_buffer_field {
typedef struct
{
- /* Pointer to internal-only port structure. */
- struct scm_port_internal *internal;
-
/* Data for the underlying port implementation as a raw C value. */
scm_t_bits stream;
- [Guile-commits] branch wip-port-refactor updated (d28d1a5 -> da456d2), Andy Wingo, 2016/05/16
- [Guile-commits] 07/21: Embed scm_t_port in scm_t_port_internal,
Andy Wingo <=
- [Guile-commits] 21/21: Bump objcode version, Andy Wingo, 2016/05/16
- [Guile-commits] 02/21: Implement lookahead-u8, get-u8 in Scheme, Andy Wingo, 2016/05/16
- [Guile-commits] 10/21: Make scm_t_port private, Andy Wingo, 2016/05/16
- [Guile-commits] 17/21: Update port mode bits documentation., Andy Wingo, 2016/05/16
- [Guile-commits] 08/21: Make file/line/column fields of ports private, Andy Wingo, 2016/05/16
- [Guile-commits] 20/21: Update NEWS for release, Andy Wingo, 2016/05/16
- [Guile-commits] 18/21: Document scm_c_make_port and friends, Andy Wingo, 2016/05/16
- [Guile-commits] 01/21: %read-char speedup, Andy Wingo, 2016/05/16
- [Guile-commits] 12/21: Update port documentation, Andy Wingo, 2016/05/16
- [Guile-commits] 04/21: Add (ice-9 sports) module, Andy Wingo, 2016/05/16