[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Proposal: block-based vector allocator
From: |
Paul Eggert |
Subject: |
Re: Proposal: block-based vector allocator |
Date: |
Thu, 07 Jun 2012 23:38:40 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux i686; rv:12.0) Gecko/20120430 Thunderbird/12.0.1 |
Thanks for working on this. Here are a few low-level comments.
On 06/07/2012 03:03 AM, Dmitry Antipov wrote:
> +#define VECTOR_FREE_LIST_FLAG \
> + ((~0) & ~(ARRAY_MARK_FLAG | PSEUDOVECTOR_FLAG \
There's no need for the "(~0) &".
> + zero_vector = (struct Lisp_Vector *)
> + pure_alloc (header_size, Lisp_Vectorlike);
No need for the cast; "zero_vector = pure_alloc (header_size, Lisp_Vectorlike)"
will work just fine. In general, it's better to avoid casts when they're
not needed, as casts are error-prone. (Admittedly the code doesn't always
follow this rule, but this was partly motivated by pre-c89 compilers.)
> +#define ADVANCE(v,nbytes) (struct Lisp_Vector *) ((char *) (v) + (nbytes))
Space after comma (here and elsewhere).
Need to parenthesize the right-hand-side.
> +#define VBLOCK_BYTES_MIN (vroundup (sizeof (struct Lisp_Vector)))
> +
> +/* Size of the largest vector allocated from block. */
> +
> +#define VBLOCK_BYTES_MAX \
> + (vroundup ((VECTOR_BLOCK_BYTES / 2) - sizeof (Lisp_Object)))
No need to parenthesize either right-hand side.
> + block = xmalloc (sizeof (struct vector_block));
> + if (!block)
> + memory_full (sizeof (struct vector_block));
The last two lines are not needed, as 'xmalloc'
already does overflow checking.
- Re: Proposal: block-based vector allocator, (continued)
- Re: Proposal: block-based vector allocator, Stefan Monnier, 2012/06/06
- Re: Proposal: block-based vector allocator, Dmitry Antipov, 2012/06/07
- Re: Proposal: block-based vector allocator, Stefan Monnier, 2012/06/07
- Re: Proposal: block-based vector allocator, Dmitry Antipov, 2012/06/08
- Re: Proposal: block-based vector allocator, Stefan Monnier, 2012/06/08
- Re: Proposal: block-based vector allocator, Dmitry Antipov, 2012/06/08
- Re: Proposal: block-based vector allocator, Eli Zaretskii, 2012/06/08
- Re: Proposal: block-based vector allocator, Eli Zaretskii, 2012/06/08
- Re: Proposal: block-based vector allocator, Eli Zaretskii, 2012/06/08
- Re: Proposal: block-based vector allocator, Eli Zaretskii, 2012/06/08
- Re: Proposal: block-based vector allocator,
Paul Eggert <=