Re: String Extension Proposal

From: Date: Fri, 01 Jul 2005 18:38:28 +0000
Subject: Re: String Extension Proposal
References: 1  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-2513@lists.php.net to get a copy of this message
Jessie, I can see how this will be useful. Two things make me hesitant about putting this in PECL right now: - String is such a generic name for a non-core class - The PHP core has a big patch for Unicode support pending (we're waiting to release 5.1 before merging it). I think there might be some merit to having some kind of String class in the core; IIRC Derick was talking about something like that with full unicode support. Let's see what the other core guys think about this before making a decision on having it in PECL. --Wez. On 7/1/05, Jessie Hernandez <jrhernandez05@gmail.com> wrote: > Hello, I've started working on an extension which declares a String > class for PHP. I already have several methods completed and will add more as > I have time. The features of this String class are the following: > > Speed/Space Management > ---------------------- > Right now, when you perform an operation such as "$value = > strtoupper($value)", a copy of the string is made, uppercased, and then > returned. This copy is unnecessary, as the original string is going to be > replaced. In this String class, all operations are done in the current > buffer. Another example, a "trim" method call simply moves the > non-whitespace characters to the beginning of the string and terminates > (sets it to '\0') the string at the first whitespace chacter at the end of > the string. > > If a copy of the string is truly needed, then the "makeCopy()" method is > just for that. You can do "$myStr->trim()" to do in-line trimming or > "$trimmedStr = $myStr->makeCopy()->trim()" to preserve the original value. > > The start size and prealloc sizes for string buffers will be configurable > through INI options. A method "reserve()" exists to reserve a specific size > for the string. If a string expects to have a lot of concatenations, > reserve()'ing an appropriate size for the string will GREATLY increase > performance and space utilization. > > > Primitive String Compatibility > ----------------------------- > The following primitive string operations ALREADY work on the current class, > compiled against PHP 5.0.4! > > <code> > $myStr = new String( "Hello World!" ); > > // get single character > echo $myStr{1}; // prints 'e' > // interpolation! > echo "The contents are: $myStr"; //prints "The contents are: Hello World!" > // regular functions! > echo strrev( $myStr ); // prints "!dlroW olleH" > </code> > > > If there are no objections, I would like to post my code to PECL. This > extension only declares one class, "String", and is meant to only work in > PHP 5 and above. > > > Regards, > > Jessie Hernandez > > -- > PECL development discussion Mailing List (http://pecl.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.pecl.dev (#2513) next »