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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: youwish dot spambot at nospam dot pls dot example dot org
New email:
PHP Version: OS:

 

 [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: Sun Nov 17 17:01:36 2019 UTC