I need more speed
authorCameron Ball <cameron@moodle.com>
Tue, 14 May 2019 05:15:15 +0000 (13:15 +0800)
committerCameron Ball <cameron@moodle.com>
Tue, 14 May 2019 05:15:15 +0000 (13:15 +0800)
src/cachehashmap.php

index 5504242..f204b1f 100644 (file)
@@ -2,15 +2,12 @@
 
 require('common.php');
 
-// $songHashMap = foldMap(
-//     ☐(∘(field(0), delemit(' ')))(∘(field(5), delemit('/')))
-// )(foldMap(∘(lines, 'trim', 'file_get_contents'))(glob(PATH_TO_GROOVENET . '/songs.*.txt')));
+$c = lines(trim(file_get_contents(glob(PATH_TO_GROOVENET . '/songs.*.txt')[0])));
+$songHashMap = [];
 
-$songHashMap = foldMap(
-    function($line) {
-        $delim = delemit('/')($line);
-        return [explode(' ', $line)[0] => $delim[4] . '/' . $delim[5]];
-    }
-)(foldMap(∘(lines, 'trim', 'file_get_contents'))(glob(PATH_TO_GROOVENET . '/songs.*.txt')));
+foreach ($c as $v) {
+    $slash = explode('/', $v);
+    $songHashMap[explode(' ', $v)[0]] = $slash[4] . '/' . $slash[5];
+}
 
 file_put_contents(__DIR__ . '/hashmap.txt', serialize($songHashMap));