php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #72492 optimize copy on write when no actual write is performed
Submitted: 2016-06-25 09:00 UTC Modified: -
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: youwish dot spambot at nospam dot pls dot example dot org Assigned:
Status: Open Package: Performance problem
PHP Version: 7.1.0alpha1 OS: Irrelevant
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [2016-06-25 09:00 UTC] youwish dot spambot at nospam dot pls dot example dot org
Description:
------------
Not very important, I'm dropping this findings here so they don't get lost in the meanders of web.

These operations (and similar ones) don't require a copy to be performed as the result is identical to the original.

Test script:
---------------
$foo = str_repeat('foo', 100000);
var_dump(memory_get_usage());
$baz = '' . $foo; // $baz is identical to $foo
var_dump(memory_get_usage());

unset($foo, $baz); echo "\n";

$foo = array_fill(0, 1000, 'foo');
var_dump(memory_get_usage());
$baz = array_merge($foo, []); // $baz is identical to $foo
var_dump(memory_get_usage());

unset($foo, $baz); echo "\n";

$foo = array_fill(0, 1000, 'foo');
var_dump(memory_get_usage());
$baz = array_slice($foo, 0); // $baz is identical to $foo
var_dump(memory_get_usage());

// etc...


Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Mon Aug 19 04:01:27 2019 UTC