mirror of
https://github.com/shuchkin/simplexlsxgen.git
synced 2023-08-10 21:12:59 +03:00
Merge pull request #4 from fredriksundin/performance
Replace array_search to optimize large arrays
This commit is contained in:
commit
9824e5b25d
@ -162,6 +162,7 @@ class SimpleXLSXGen {
|
||||
}
|
||||
|
||||
$SI = [];
|
||||
$SI_KEYS = [];
|
||||
$COLS = [];
|
||||
$ROWS = [];
|
||||
if ( count($this->rows) ) {
|
||||
@ -212,10 +213,15 @@ class SimpleXLSXGen {
|
||||
} else {
|
||||
$ct = 's'; // shared string
|
||||
$v = str_replace(['&','<','>'],['&','<','>'], $v);
|
||||
$cv = array_search( $v, $SI, true );
|
||||
$cv = false;
|
||||
if ( isset($SI_KEYS[$v]) && $SI[$SI_KEYS[$v]] === $v ) {
|
||||
$cv = $SI_KEYS[$v];
|
||||
}
|
||||
|
||||
if ( $cv === false ) {
|
||||
$SI[] = $v;
|
||||
$cv = count( $SI ) - 1;
|
||||
$SI_KEYS[$v] = $cv;
|
||||
}
|
||||
}
|
||||
} elseif ( is_int( $v ) || is_float( $v ) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user