Skip to content

Commit

Permalink
[TASK] Use cast for up to 6x higher speed
Browse files Browse the repository at this point in the history
  • Loading branch information
simonschaufi committed Mar 26, 2024
1 parent a0e462a commit 8c2b5ae
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
20 changes: 10 additions & 10 deletions Classes/Controller/PluginController.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private function extractGroup($record_ids)
break;
}
foreach ($items as $item) {
$item = intval($item);
$item = (int) $item;

$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable($table);
Expand Down Expand Up @@ -453,17 +453,17 @@ private function extractGroup($record_ids)
case 'tx_odsosm_track':
case 'tx_odsosm_vector':
if ($row['min_lon']) {
$this->lons[] = floatval($row['min_lon']);
$this->lats[] = floatval($row['min_lat']);
$this->lons[] = floatval($row['max_lon']);
$this->lats[] = floatval($row['max_lat']);
$this->lons[] = (float) $row['min_lon'];
$this->lats[] = (float) $row['min_lat'];
$this->lons[] = (float) $row['max_lon'];
$this->lats[] = (float) $row['max_lat'];
} else {
unset($records[$table][$uid]);
}
break;
default:
$this->lons[] = floatval($row['longitude']);
$this->lats[] = floatval($row['latitude']);
$this->lons[] = (float) $row['longitude'];
$this->lats[] = (float) $row['latitude'];
break;
}
}
Expand Down Expand Up @@ -628,10 +628,10 @@ public function getMap()
$lon = array_sum($this->lons) / count($this->lons);
$lat = array_sum($this->lats) / count($this->lats);
} else {
$lon = floatval($this->config['lon'] ?? $this->config['default_lon']);
$lat = floatval($this->config['lat'] ?? $this->config['default_lat']);
$lon = (float)($this->config['lon'] ?? $this->config['default_lon']);
$lat = (float)($this->config['lat'] ?? $this->config['default_lat']);
}
$zoom = intval($this->config['zoom']);
$zoom = (int)$this->config['zoom'];

/* ==================================================
Map
Expand Down
4 changes: 2 additions & 2 deletions Classes/Div.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ public static function searchAddress(&$address, $service = 0)
'tstamp' => time(),
'cache_hit' => $row['cache_hit'] + 1,
];
$connection->update('tx_odsosm_geocache', $set, ['uid' => intval($row['uid'])]);
$connection->update('tx_odsosm_geocache', $set, ['uid' => (int) $row['uid']]);

$address['lat'] = $row['lat'];
$address['lon'] = $row['lon'];
Expand Down Expand Up @@ -429,7 +429,7 @@ public static function updateCache($address, $search = [])
'tstamp' => time(),
'service_hit' => $row['service_hit'] + 1,
];
$connection->update('tx_odsosm_geocache', $set, ['uid' => intval($row['uid'])]);
$connection->update('tx_odsosm_geocache', $set, ['uid' => (int) $row['uid']]);
} else {
$set['tstamp'] = time();
$set['crdate'] = time();
Expand Down
8 changes: 4 additions & 4 deletions Classes/Provider/Staticmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ public function getMap($layers, $markers, $lon, $lat, $zoom)
}

// set reasonable defaults for width and height (100% and vh/vw does not work with staticmap)
if (intval($this->config['width']) <= 100) {
if ((int)$this->config['width'] <= 100) {
$this->config['width'] = 640;
}
if (intval($this->config['height']) <= 100) {
if ((int)$this->config['height'] <= 100) {
$this->config['height'] = 480;
}

Expand All @@ -47,8 +47,8 @@ public function getMap($layers, $markers, $lon, $lat, $zoom)
'###lon###' => $lon,
'###lat###' => $lat,
'###zoom###' => $zoom,
'###width###' => intval($this->config['width']),
'###height###' => intval($this->config['height']),
'###width###' => (int)$this->config['width'],
'###height###' => (int)$this->config['height'],
];

$layer = array_shift($layers);
Expand Down
2 changes: 1 addition & 1 deletion Classes/TceMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ public function processDatamap_postProcessFieldArray($status, $table, $id, &$fie
$address[$def] = $obj->datamap[$table][$id][$field];
}
}
if ($config['autocomplete'] == 2 || floatval($address['longitude'] ?? 0) == 0) {
if ($config['autocomplete'] == 2 || (float) ($address['longitude'] ?? 0) == 0) {
$ll = Div::updateAddress($address);
if ($ll) {
// Optimize address
Expand Down

0 comments on commit 8c2b5ae

Please sign in to comment.