mirror of
https://github.com/danog/PrimeModule.git
synced 2024-11-26 20:34:37 +01:00
Cache FFI
This commit is contained in:
parent
4b23fd24b2
commit
fbb45df47d
@ -10,14 +10,27 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=7.0"
|
"php": "^8.0"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-primemodule": "Install the native C++ extension for extremely fast factorization (https://github.com/danog/PrimeModule-ext)"
|
"ext-primemodule": "Install the native C++ extension for extremely fast factorization (https://prime.madelineproto.xyz)"
|
||||||
},
|
},
|
||||||
"autoload": {
|
"autoload": {
|
||||||
"psr-0": {
|
"psr-0": {
|
||||||
"danog\\": "lib/"
|
"danog\\": "lib/"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"config": {
|
||||||
|
"allow-plugins": {
|
||||||
|
"phabel/phabel": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phabel/phabel": "^1"
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"phabel": {
|
||||||
|
"revision": 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -218,13 +218,14 @@ class PrimeModule
|
|||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static ?FFI $ffi = null;
|
||||||
public static function native_single_cpp($what)
|
public static function native_single_cpp($what)
|
||||||
{
|
{
|
||||||
if (!extension_loaded('primemodule')) {
|
if (!extension_loaded('primemodule')) {
|
||||||
if (class_exists(FFI::class)) {
|
if (class_exists(FFI::class)) {
|
||||||
try {
|
try {
|
||||||
$ffi = FFI::load('/usr/include/primemodule-ffi.h');
|
self::$ffi = FFI::load('/usr/include/primemodule-ffi.h');
|
||||||
$result = $ffi->factorizeFFI((string) $what);
|
$result = self::$ffi->factorizeFFI((string) $what);
|
||||||
if ($result > 0) {
|
if ($result > 0) {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user