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

[perl #128226] Remove the requirement for null termination on PVs

Thread Next
From:
Father Chrysostomos
Date:
May 23, 2016 23:51
Subject:
[perl #128226] Remove the requirement for null termination on PVs
Message ID:
rt-4.0.18-23916-1464047489-280.128226-75-0@perl.org
# New Ticket Created by  Father Chrysostomos 
# Please include the string:  [perl #128226]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=128226 >


If we could remove the requirement that PVs in SVs have a terminating null, we could make things like substr() faster (by having it use the same string buffer as the full original string).

Since it is not uncommon in XS code to pass SvPV(...) to a system function that expects null termination, we would probably have to make SvPV allocate a new string with the null, and introduce a new version of SvPV (SvPV_nn_ok(sv,len)?) that may return unterminated strings and assumes the caller will depend solely on the len value.

Of course, any code that passes SvPVX to a C function will probably break.  I don’t know whether there is any way to avoid that.  A survey of SvPVX uses on CPAN would be time-consuming, but helpful.

-- 

Father Chrysostomos


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