[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
- Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?, Rik, 2017/07/18
- Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?, John W. Eaton, 2017/07/18
- Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?, Rik, 2017/07/19
- Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?, John W. Eaton, 2017/07/19
- Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?, Rik, 2017/07/20
- Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?, John W. Eaton, 2017/07/20
- Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?,
Rik <=
- Message not available
- Message not available
- Message not available
- Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?, Daniel J Sebald, 2017/07/21
- Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?, Daniel J Sebald, 2017/07/23
- Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?, John W. Eaton, 2017/07/21
- Re: Replace OCTAVE_LOCAL_BUFFER implementation with std::unique_ptr?, Mike Miller, 2017/07/21
- Re: initialization style, Rik, 2017/07/21