octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?


From: Rik
Subject: Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?
Date: Thu, 20 Jul 2017 21:31:32 -0700

On 07/20/2017 04:39 PM, John W. Eaton wrote:
>
>> Also, while looking through the code I found instances where
>> OCTAVE_LOCAL_BUFFER was being used with constants that are small and fixed
>> at compile time.  Given that OCTAVE_LOCAL_BUFFER is designed for dynamic,
>> and possibly large, buffers which are stored on the heap, I believe it
>> makes sense to replace these instances with local variables which would be
>> stored on the stack.  As an example,
>>
>> corefcn/load-save.cc:225:  OCTAVE_LOCAL_BUFFER (unsigned char, magic, 2);
>>
>> A 2-byte scratchpad just isn't worth the new/delete overhead.
>
> Yes, definitely not worth it and should be replaced with just
>
>   "unsigned char magic[2];"
>
> But this change should only be made in cases where the size really is a
> constant.

There were only a few instances of static buffers which I changed to use
local variables in this cset
(http://hg.savannah.gnu.org/hgweb/octave/rev/cda0614beaec).

--Rik



reply via email to

[Prev in Thread] Current Thread [Next in Thread]