This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#pragma warning(push) | |
#pragma warning(disable:4996) | |
#include <cassert> | |
#include <memory> | |
#include <vector> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$a = "1"; | |
$b = "2"; | |
/** | |
* This should reuse the decimal created for A as the result. | |
*/ | |
$c = \Decimal\Decimal::valueOf($a)->add($b); | |
debug_zval_dump($c); | |
// object(Decimal\Decimal)#1 (2) refcount(2){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
interface Collection | |
{ | |
/** | |
* @return static | |
*/ | |
function map(callable cb): Collection; | |
// filter | |
// reduce |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Decimal\Decimal; | |
/* Number of times to perform each calculation. */ | |
$iterations = 1000000; | |
/* Candidates */ | |
define("DECIMAL", "decimal"); | |
define("BC_MATH", "bcmath"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
ini_set('memory_limit', -1); | |
srand(0); | |
$length = 100000; | |
$maxInt = 10 ** 10; | |
$values = []; | |
for ($i = 0; $i < $length; $i++) { | |
$int = (rand() % $maxInt); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// See https://github.com/php/php-src/pull/3351 | |
$arr = [ | |
"foo" => true, | |
"foobar" => 3, | |
"elePHPant" => "qux", | |
"long_key_name" => "something contrived", | |
"123" => 76, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prefetched_related(instance, name, default=None): | |
""" | |
Attempts to find and return prefetched data on a model. | |
Usage: | |
values, prefetched = prefetched_related(instance, 'name') | |
values : A list of prefetched values for the field. | |
prefetched : True if the requested field was prefetched on the instance. | |
""" |