[php-src] Issue #10864: Can we get compile time routines?
| From: | divinity76 | Date: | Thu, 16 Mar 2023 09:12:04 +0000 |
| Subject: | [php-src] Issue #10864: Can we get compile time routines? | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-243913@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/10864
Author: divinity76
### Description
I have a large multi-megabyte JSON that is currently parsed several times per second, I also have
OPCache enabled, would save time if the parsing could be done at compile-time rather than runtime,
would be nice if i could do something like
```php
$data = compile_time_routine(function() {
return json_decode("large.json",true);
});
```
instead of
```php
$data = json_decode("large.json",true);
```
with it being equivalent at runtime to
```
$data = array(...whatever json_decode returned...);
```
another example would be
```
echo "opcache compiled at " . compile_time_routine(function(){return
date(DateTime::RFC3339);});
```
being equivalent at runtime to
```
echo "opcache compiled at " . "2023-03-16T09:43:00+01:00";
```
(i did not give the function name/argument/details much thought fwiw)