[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Nano-devel] [PATCH] chars: use a fixed piece of memory instead allo
Re: [Nano-devel] [PATCH] chars: use a fixed piece of memory instead allocating+freeing all the time
Sat, 17 Dec 2016 12:33:53 +0100
On Sat, Dec 17, 2016, at 00:28, Mike Frysinger wrote:
> at face value, this is kind of scary.
It is. That's why I sent it to the list. :)
> are there guarantees
> to keep re-use from happening across funcs/modules ?
No, nothing other than paying attention.
> can't we utilize the stack for this ?
> char symbol[mb_cur_max() + 1];
Yes. Much better. I didn't know this was possible.
Adjusted patch is coming up.
> seems like mb_cur_max() should be made into an inline func
> too ...
I tried some inlining once, but it didn't make any difference in
the generated code. But now I realize that this must have been
because I use '-Os' by default. When using '-O2', the inline
marker does make a difference (it even makes gcc reorder some
functions so it needs some cutting and pasting to be able to see
the real differences). But... exactly for the above call (in
the declaration of a variable), gcc does /not/ inline it.
(As nano only supports UTF-8 and plain ASCII, we could just
use 4 instead of mb_cur_max() -- much quicker.)
(To compare generated code, I use:
gcc -S -O2 -include config.h src/somefile.c
where the assembly code lands in somefile.s.)
http://www.fastmail.com - Accessible with your email software
or over the web