Skip to content

Commit c1e4f9f

Browse files
committed
Use type casting instead of *val() method
It should be up to 6x faster Signed-off-by: Morris Jobke <hey@morrisjobke.de>
1 parent fe7e726 commit c1e4f9f

File tree

30 files changed

+62
-62
lines changed

30 files changed

+62
-62
lines changed

apps/comments/appinfo/app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function() {
3636

3737
$eventDispatcher->addListener(\OCP\Comments\CommentsEntityEvent::EVENT_ENTITY, function(\OCP\Comments\CommentsEntityEvent $event) {
3838
$event->addEntityCollection('files', function($name) {
39-
$nodes = \OC::$server->getUserFolder()->getById(intval($name));
39+
$nodes = \OC::$server->getUserFolder()->getById((int)$name);
4040
return !empty($nodes);
4141
});
4242
});

apps/dav/lib/CalDAV/Search/Xml/Filter/LimitFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ static function xmlDeserialize(Reader $reader) {
4040
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}limit has illegal value');
4141
}
4242

43-
return intval($value);
43+
return (int)$value;
4444
}
4545
}

apps/dav/lib/CalDAV/Search/Xml/Filter/OffsetFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ static function xmlDeserialize(Reader $reader) {
4040
throw new BadRequest('The {' . SearchPlugin::NS_Nextcloud . '}offset has illegal value');
4141
}
4242

43-
return intval($value);
43+
return (int)$value;
4444
}
4545
}

apps/dav/lib/Connector/Sabre/CommentPropertiesPlugin.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public function handleGetProperties(
9797
}
9898

9999
$propFind->handle(self::PROPERTY_NAME_COUNT, function() use ($node) {
100-
return $this->commentsManager->getNumberOfCommentsForObject('files', strval($node->getId()));
100+
return $this->commentsManager->getNumberOfCommentsForObject('files', (string)$node->getId());
101101
});
102102

103103
$propFind->handle(self::PROPERTY_NAME_HREF, function() use ($node) {
@@ -153,9 +153,9 @@ public function getUnreadCount(Node $node) {
153153
return null;
154154
}
155155

156-
$lastRead = $this->commentsManager->getReadMark('files', strval($node->getId()), $user);
156+
$lastRead = $this->commentsManager->getReadMark('files', (string)$node->getId(), $user);
157157

158-
return $this->commentsManager->getNumberOfCommentsForObject('files', strval($node->getId()), $lastRead);
158+
return $this->commentsManager->getNumberOfCommentsForObject('files', (string)$node->getId(), $lastRead);
159159
}
160160

161161
}

apps/dav/lib/Connector/Sabre/Node.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ protected function sanitizeMtime($mtimeFromRequest) {
369369
throw new \InvalidArgumentException('X-OC-MTime header must be an integer (unix timestamp).');
370370
}
371371

372-
return intval($mtimeFromRequest);
372+
return (int)$mtimeFromRequest;
373373
}
374374

375375
}

apps/dav/lib/SystemTag/SystemTagsRelationsCollection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function __construct(
6060
$userSession,
6161
$groupManager,
6262
function($name) {
63-
$nodes = \OC::$server->getUserFolder()->getById(intval($name));
63+
$nodes = \OC::$server->getUserFolder()->getById((int)$name);
6464
return !empty($nodes);
6565
}
6666
),

apps/files_external/3rdparty/icewind/smb/src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function parseStat($output) {
133133
return [
134134
'mtime' => strtotime($data['write_time']),
135135
'mode' => hexdec(substr($data['attributes'], strpos($data['attributes'], '('), -1)),
136-
'size' => isset($data['stream']) ? intval(explode(' ', $data['stream'])[1]) : 0
136+
'size' => isset($data['stream']) ? (int)explode(' ', $data['stream'])[1] : 0
137137
];
138138
}
139139

apps/files_trashbin/lib/Expiration.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -142,13 +142,13 @@ private function parseRetentionObligation(){
142142
$this->canPurgeToSaveSpace = true;
143143
} elseif ($minValue !== 'auto' && $maxValue === 'auto') {
144144
// Keep for X days but delete anytime if space needed
145-
$this->minAge = intval($minValue);
145+
$this->minAge = (int)$minValue;
146146
$this->maxAge = self::NO_OBLIGATION;
147147
$this->canPurgeToSaveSpace = true;
148148
} elseif ($minValue === 'auto' && $maxValue !== 'auto') {
149149
// Delete anytime if space needed, Delete all older than max automatically
150150
$this->minAge = self::NO_OBLIGATION;
151-
$this->maxAge = intval($maxValue);
151+
$this->maxAge = (int)$maxValue;
152152
$this->canPurgeToSaveSpace = true;
153153
} elseif ($minValue !== 'auto' && $maxValue !== 'auto') {
154154
// Delete all older than max OR older than min if space needed
@@ -158,8 +158,8 @@ private function parseRetentionObligation(){
158158
$maxValue = $minValue;
159159
}
160160

161-
$this->minAge = intval($minValue);
162-
$this->maxAge = intval($maxValue);
161+
$this->minAge = (int)$minValue;
162+
$this->maxAge = (int)$maxValue;
163163
$this->canPurgeToSaveSpace = false;
164164
}
165165
}

apps/files_versions/lib/Expiration.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,13 +175,13 @@ private function parseRetentionObligation(){
175175
$this->canPurgeToSaveSpace = true;
176176
} elseif ($minValue !== 'auto' && $maxValue === 'auto') {
177177
// Keep for X days but delete anytime if space needed
178-
$this->minAge = intval($minValue);
178+
$this->minAge = (int)$minValue;
179179
$this->maxAge = self::NO_OBLIGATION;
180180
$this->canPurgeToSaveSpace = true;
181181
} elseif ($minValue === 'auto' && $maxValue !== 'auto') {
182182
// Delete anytime if space needed, Delete all older than max automatically
183183
$this->minAge = self::NO_OBLIGATION;
184-
$this->maxAge = intval($maxValue);
184+
$this->maxAge = (int)$maxValue;
185185
$this->canPurgeToSaveSpace = true;
186186
} elseif ($minValue !== 'auto' && $maxValue !== 'auto') {
187187
// Delete all older than max OR older than min if space needed
@@ -191,8 +191,8 @@ private function parseRetentionObligation(){
191191
$maxValue = $minValue;
192192
}
193193

194-
$this->minAge = intval($minValue);
195-
$this->maxAge = intval($maxValue);
194+
$this->minAge = (int)$minValue;
195+
$this->maxAge = (int)$maxValue;
196196
$this->canPurgeToSaveSpace = false;
197197
}
198198
}

apps/files_versions/lib/Storage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ public static function expireOlderThanMaxForUser($uid){
503503

504504
$toDelete = [];
505505
foreach (array_reverse($versions['all']) as $key => $version) {
506-
if (intval($version['version'])<$threshold) {
506+
if ((int)$version['version'] <$threshold) {
507507
$toDelete[$key] = $version;
508508
} else {
509509
//Versions are sorted by time - nothing mo to iterate.

0 commit comments

Comments
 (0)