Req #76827 [NEW]: Introduce a new function struncate or some such

From: Date: Fri, 31 Aug 2018 08:27:37 +0000
Subject: Req #76827 [NEW]: Introduce a new function struncate or some such
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-216821@lists.php.net to get a copy of this message
From:             zjz at zjz dot name
Operating system: 
PHP version:      Irrelevant
Package:          Performance problem
Bug Type:         Feature/Change Request
Bug description:Introduce a new function struncate or some such

Description:
------------
Please consider introducing a new function |struncate| or some such to
resolve the performance problem of truncate a very long string to a
slightly shorter one.

For example, suppose the user wants to truncate a 50000 byte string to a
49999 byte string(i.e. to delete the last character), and **the
untruncated one is no longer in use**.

Right now the user has to write code as such:

$str = substr($str, 0, -1);

However, this is silly, it is rather bad in performance when the string
copying is not necessary as the untruncated one is no longer in use as
mentioned above.

So I'd like to suggest adding a new function |struncate|, which receives
two parameters, one is a reference of a string to be truncated, the
other is the truncated length:

function struncate(&$string, $length)


-- 
Edit bug report at https://bugs.php.net/bug.php?id=76827&edit=1
-- 
Try a snapshot (PHP 5.4):   https://bugs.php.net/fix.php?id=76827&r=trysnapshot54
Try a snapshot (PHP 5.5):   https://bugs.php.net/fix.php?id=76827&r=trysnapshot55
Try a snapshot (trunk):     https://bugs.php.net/fix.php?id=76827&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=76827&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=76827&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=76827&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=76827&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=76827&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=76827&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=76827&r=notwrong
Not enough info:            https://bugs.php.net/fix.php?id=76827&r=notenoughinfo
Submitted twice:            https://bugs.php.net/fix.php?id=76827&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=76827&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76827&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=76827&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=76827&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=76827&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76827&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=76827&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=76827&r=mysqlcfg



Thread (15 messages)

« previous php.bugs (#216821) next »