1
0
mirror of https://github.com/vichan-devel/vichan.git synced 2024-11-23 23:20:57 +01:00

fix "scandir should not need to sort in b.php (banner code)"

scandir by default sorts files in ascending order. this is unnecessary when you're picking a random file anyway. it's just wasting CPU cycles and increasing latency as more files are added.

currently it is

    $files = scandir($dir);

it should be

    $files = scandir($dir, SCANDIR_SORT_NONE);
This commit is contained in:
Majin Bejitto 2022-12-21 03:25:49 -05:00 committed by Fred Brennan
parent 70222e8c2d
commit 4e8c69ba48

2
b.php
View File

@ -1,6 +1,6 @@
<?php
$dir = "static/banners/";
$files = scandir($dir);
$files = scandir($dir, SCANDIR_SORT_NONE);
$images = array_diff($files, array('.', '..'));
$name = $images[array_rand($images)];
// open the file in a binary mode