File 0635-erl_tar-Use-read_ahead-when-reading-compressed-tar-f.patch of Package erlang

From 46e1565e73bc4490d29f0193146d4d75d9dba226 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?John=20H=C3=B6gberg?= <john@erlang.org>
Date: Thu, 28 Mar 2019 11:59:47 +0100
Subject: [PATCH 2/2] erl_tar: Use read_ahead when reading compressed tar files

Jumping around in a compressed file is nowhere near as cheap as
for uncompressed files, as it requires reading and decompressing
up until the desired position. Using read_ahead will improve
performance slightly.
---
 lib/stdlib/src/erl_tar.erl | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/stdlib/src/erl_tar.erl b/lib/stdlib/src/erl_tar.erl
index d8b8f466b1..7064fcacfa 100644
--- a/lib/stdlib/src/erl_tar.erl
+++ b/lib/stdlib/src/erl_tar.erl
@@ -324,7 +324,7 @@ do_open(Name, Mode) when is_list(Mode) ->
 open1({binary,Bin}, read, _Raw, Opts) when is_binary(Bin) ->
     case file:open(Bin, [ram,binary,read]) of
         {ok,File} ->
-            _ = [ram_file:uncompress(File) || Opts =:= [compressed]],
+            _ = [ram_file:uncompress(File) || lists:member(compressed, Opts)],
             {ok, #reader{handle=File,access=read,func=fun file_op/2}};
         Error ->
             Error
@@ -357,7 +357,7 @@ open_mode([read|Rest], false, Raw, Opts) ->
 open_mode([write|Rest], false, Raw, Opts) ->
     open_mode(Rest, write, Raw, Opts);
 open_mode([compressed|Rest], Access, Raw, Opts) ->
-    open_mode(Rest, Access, Raw, [compressed|Opts]);
+    open_mode(Rest, Access, Raw, [compressed,read_ahead|Opts]);
 open_mode([cooked|Rest], Access, _Raw, Opts) ->
     open_mode(Rest, Access, [], Opts);
 open_mode([], Access, Raw, Opts) ->
-- 
2.16.4