mirror of
https://github.com/rr-/szurubooru.git
synced 2025-07-17 08:26:24 +00:00
Micro optimalizations
Saved 0.015s on various things, mostly thanks to new chibi-core caching
This commit is contained in:
Submodule lib/chibi-core updated: 971fba5cb9...9653960e23
@ -20,7 +20,7 @@ class TextHelper
|
||||
//todo: convert to enum and make one method
|
||||
public static function snakeCaseToCamelCase($string, $lower = false)
|
||||
{
|
||||
$string = preg_split('/_/', $string);
|
||||
$string = explode('_', $string);
|
||||
$string = array_map('trim', $string);
|
||||
$string = array_map('ucfirst', $string);
|
||||
$string = join('', $string);
|
||||
@ -31,7 +31,7 @@ class TextHelper
|
||||
|
||||
public static function kebabCaseToCamelCase($string)
|
||||
{
|
||||
$string = preg_split('/-/', $string);
|
||||
$string = explode('-', $string);
|
||||
$string = array_map('trim', $string);
|
||||
$string = array_map('ucfirst', $string);
|
||||
$string = join('', $string);
|
||||
|
@ -79,9 +79,22 @@ abstract class AbstractCrudModel implements IModel
|
||||
|
||||
public static function convertRows(array $rows)
|
||||
{
|
||||
$keyCache = [];
|
||||
$entities = [];
|
||||
foreach ($rows as $i => $row)
|
||||
$rows[$i] = self::convertRow($row);
|
||||
return $rows;
|
||||
{
|
||||
$entity = self::spawn();
|
||||
foreach ($row as $key => $val)
|
||||
{
|
||||
if (isset($keyCache[$key]))
|
||||
$key = $keyCache[$key];
|
||||
else
|
||||
$key = $keyCache[$key] = TextHelper::snakeCaseToCamelCase($key, true);
|
||||
$entity->$key = $val;
|
||||
}
|
||||
$entities[$i] = $entity;
|
||||
}
|
||||
return $entities;
|
||||
}
|
||||
|
||||
|
||||
|
@ -14,6 +14,9 @@ class PostEntity extends AbstractEntity
|
||||
public $imageHeight;
|
||||
public $uploaderId;
|
||||
public $source;
|
||||
public $commentCount;
|
||||
public $favCount;
|
||||
public $score;
|
||||
|
||||
public function getUploader()
|
||||
{
|
||||
|
Reference in New Issue
Block a user