Apply suggestion to lib/pleroma/emoji/loader.ex
authorMaksim <parallel588@gmail.com>
Thu, 29 Aug 2019 11:45:25 +0000 (11:45 +0000)
committerMaksim Pechnikov <parallel588@gmail.com>
Fri, 30 Aug 2019 04:30:54 +0000 (07:30 +0300)
lib/pleroma/emoji/loader.ex

index 70eba9ac681d4cd5dd207b3a5f49a207b56172bb..82fc3b8c34b9834ef155cb3313744ddc7b3dd176 100644 (file)
@@ -122,19 +122,17 @@ defmodule Pleroma.Emoji.Loader do
   end
 
   def find_all_emoji(dir, exts) do
-    Enum.reduce(
-      File.ls!(dir),
-      [],
-      fn f, acc ->
-        filepath = Path.join(dir, f)
-
-        if File.dir?(filepath) do
-          acc ++ find_all_emoji(filepath, exts)
-        else
-          acc ++ [filepath]
-        end
+    dir
+    |> File.ls!()
+    |> Enum.flat_map(fn f ->
+      filepath = Path.join(dir, f)
+
+      if File.dir?(filepath) do
+        find_all_emoji(filepath, exts)
+      else
+        [filepath]
       end
-    )
+    end)
     |> Enum.filter(fn f -> Path.extname(f) in exts end)
   end