diff options
author | Justus Winter <[email protected]> | 2017-01-30 14:51:19 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2017-01-30 17:21:24 +0000 |
commit | 49e2ae65e892f93be7f87cfaae3392b50a99e4b1 (patch) | |
tree | 3f6fdefe15b86ce7893ad95d8c6aae7c64ba9bfb /tests/gpgscm/scheme-private.h | |
parent | gpgscm: Provide framework for immediate values. (diff) | |
download | gnupg-49e2ae65e892f93be7f87cfaae3392b50a99e4b1.tar.gz gnupg-49e2ae65e892f93be7f87cfaae3392b50a99e4b1.zip |
gpgscm: Use a compact vector representation.
* tests/gpgscm/scheme-private.h (struct cell): Add a compact vector
representation.
* tests/gpgscm/scheme.c (vector_length): Use new representation.
(vector_size): New macro.
(get_vector_object): Use the new representation.
(fill_vector): Likewise.
(vector_elem): Likewise.
(set_vector_elem): Likewise.
(mark): Likewise.
(gc): Likewise. Be careful not to confuse immediate values for type
flags.
(finalize_cell): Vectors now require finalization.
--
Previously, vectors were represented using consecutive cons cells,
wasting one word per cell for the type information. Fix that by using
a flat array.
Previously, a vector of size N required 1 + (n + 1) / 2 cells. Now it
uses 1 + (n - 1 + 2) / 3 cells.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'tests/gpgscm/scheme-private.h')
-rw-r--r-- | tests/gpgscm/scheme-private.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/tests/gpgscm/scheme-private.h b/tests/gpgscm/scheme-private.h index aba2319b4..ad8f57142 100644 --- a/tests/gpgscm/scheme-private.h +++ b/tests/gpgscm/scheme-private.h @@ -56,6 +56,10 @@ struct cell { struct cell *_cdr; } _cons; struct { + size_t _length; + pointer _elements[0]; + } _vector; + struct { char *_data; const foreign_object_vtable *_vtable; } _foreign_object; |