develooper Front page | perl.perl5.porters | Postings from May 2013

Re: SV_CHECK_THINKFIRST() needs to be rethought and further COW woes....

Thread Previous | Thread Next
From:
Leon Timmermans
Date:
May 11, 2013 18:57
Subject:
Re: SV_CHECK_THINKFIRST() needs to be rethought and further COW woes....
Message ID:
CAHhgV8g6H0G5p=eyg5zLPgJ52D9PGwtWfmvj-rJpgYyFkVVmvw@mail.gmail.com
On Fri, May 10, 2013 at 9:56 AM, Tony Cook <tony@develop-help.com> wrote:
> So should we provide an API that abstracts access to the buffer so
> that modules that want direct access for performance can safely access
> it?
>
> Maybe:
>
> /* before I touch the buffer */
> char *sv_buffer_lock(sv, size, flags);
>
> SBLf_UTF8 - make the existing buffer UTF-8 (ignored for SBLf_UNINIT)
>
> SBLf_BYTES - make existing buffer bytes (ignored for SBLf_UNINIT)
>
> SBLf_UNINIT - just give me a buffer, I'll only write to it (a debug
> perl might fill it with trash)
>
> SBLf_CROAK - croak if SBLf_BYTES can't be honoured.
>
> SBLf_NOMAGIC - don't SvGETMAGIC()
>
> /* I need more space */
> char *sv_buffer_grow(sv, size, flags);
>
> valid flags:
> SBLf_UNINIT - ignore the existing data
>
> /* I've finished, offset would commonly be 0 */
> void sv_buffer_unlock(sv, offset, size, flags);
>
> SBLf_UTF8 - the new data is UTF-8 (ignore the previous flag set)
>
> SBLf_BYTES - the new data is bytes/latin1 (ignore the previous flag set)
>
> SBLf_DISCARD - just make it undef (offset, size ignored)
>
> SBLf_NOMAGIC - don't SvSETMAGIC()
>
> A debugging perl could panic() if SvPVfoo() was called on a buffer
> locked SV.

I don't like this idea of locking/unlocking. It feels to me like too
much complexity.

Leon

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About