Skip to content

Commit 6643c01

Browse files
committed
update: use associative arrays for faster lookups [micro-optimization].
1 parent 973a4da commit 6643c01

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

src/Migration/Sources/CSV.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,11 +172,11 @@ private function exportRows(int $batchSize): void
172172
$relationType === 'manyToMany' &&
173173
$relationSide === 'parent'
174174
) {
175-
$manyToManyKeys[] = $key;
175+
$manyToManyKeys[$key] = true;
176176
}
177177

178178
if ($isArray && $type !== Column::TYPE_RELATIONSHIP) {
179-
$arrayKeys[] = $key;
179+
$arrayKeys[$key] = true;
180180
}
181181
}
182182

@@ -210,7 +210,7 @@ private function exportRows(int $batchSize): void
210210
continue;
211211
}
212212

213-
if (in_array($key, $manyToManyKeys, true)) {
213+
if (isset($manyToManyKeys[$key])) {
214214
$parsedData[$key] = $parsedValue === ''
215215
? []
216216
: array_values(
@@ -224,7 +224,7 @@ private function exportRows(int $batchSize): void
224224
continue;
225225
}
226226

227-
if (in_array($key, $arrayKeys, true)) {
227+
if (isset($arrayKeys[$key])) {
228228
if ($parsedValue === '') {
229229
$parsedData[$key] = [];
230230
} else {

0 commit comments

Comments
 (0)