Use `isset()` instead of `in_array()` for increased performance and code simplification

Closes #82

Signed-off-by: Roland Häder <roland@mxchange.org>
This commit is contained in:
Roland Häder 2017-02-10 09:18:09 +01:00 committed by Adrien Crivelli
parent 6b77a30093
commit 99e5a8e919
No known key found for this signature in database
GPG Key ID: B182FD79DC6DE92E
2 changed files with 6 additions and 4 deletions

View File

@ -547,7 +547,7 @@ class ReferenceHelper
$autoFilterRange = $autoFilter->getRange();
if (!empty($autoFilterRange)) {
if ($pNumCols != 0) {
$autoFilterColumns = array_keys($autoFilter->getColumns());
$autoFilterColumns = $autoFilter->getColumns();
if (count($autoFilterColumns) > 0) {
sscanf($pBefore, '%[A-Z]%d', $column, $row);
$columnIndex = Cell::columnIndexFromString($column);
@ -559,7 +559,7 @@ class ReferenceHelper
$deleteColumn = $columnIndex + $pNumCols - 1;
$deleteCount = abs($pNumCols);
for ($i = 1; $i <= $deleteCount; ++$i) {
if (in_array(Cell::stringFromColumnIndex($deleteColumn), $autoFilterColumns)) {
if (isset($autoFilterColumns[Cell::stringFromColumnIndex($deleteColumn)])) {
$autoFilter->clearColumn(Cell::stringFromColumnIndex($deleteColumn));
}
++$deleteColumn;

View File

@ -518,8 +518,10 @@ class Worksheet extends BIFFwriter
foreach ($conditionalStyles as $conditional) {
if ($conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_EXPRESSION
|| $conditional->getConditionType() == \PhpOffice\PhpSpreadsheet\Style\Conditional::CONDITION_CELLIS) {
if (!in_array($conditional->getHashCode(), $arrConditional)) {
$arrConditional[] = $conditional->getHashCode();
if (!isset($arrConditional[$conditional->getHashCode()])) {
// This hash code has been handled
$arrConditional[$conditional->getHashCode()] = true;
// Write CFRULE record
$this->writeCFRule($conditional);
}