From: John Carr <jfc@MIT.EDU>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Re: zcat vs CamlZip
Date: Tue, 29 Aug 2006 15:37:41 -0400 [thread overview]
Message-ID: <200608291937.k7TJbfWP016413@contents-vnder-pressvre.mit.edu> (raw)
In-Reply-To: Your message of "Tue, 29 Aug 2006 20:54:17 +0200." <ed22gp$un$1@sea.gmane.org>
> This is your most likely culprit. Any kind of "do this for every
> character" is usually insanely expensive when you can do it in bulk.
I wrote a program that read data from a text file, which
could optionally be compressed. I defined my text file
format to have nearly-fixed length lines so I could call
Gzip.really_input. My program doesn't spend much of its
time reading the text file so I didn't spend much time
making input fast. I just did what I thought the obvious
optimization of reading a block of characters in the
normal case.
let input_line =
begin function
Uncompressed c ->
input_line c
| Compressed c ->
begin match Gzip.input_char c with
'#' -> while Gzip.input_char c <> '\n' do () done; "#"
| 'S' ->
let buf = String.make 11 'S' in
Gzip.really_input c buf 1 10;
if String.unsafe_get buf 10 = '\n' then
String.unsafe_set buf 10 ' '
else begin
if Gzip.input_char c <> '\n' then
failwith "bad override file"
end;
buf
| _ -> failwith "bad override file"
end
end
(Lines are variable-length comments beginning '#' or data
lines beginning with 'S' followed by 9 or 10 characters.)
next prev parent reply other threads:[~2006-08-29 19:37 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-29 18:40 Sam Steingold
2006-08-29 18:54 ` Bardur Arantsson
2006-08-29 19:01 ` [Caml-list] " Florian Hars
2006-08-29 19:15 ` Sam Steingold
2006-08-29 19:48 ` Bárður Árantsson
2006-08-29 19:54 ` [Caml-list] " Gerd Stolpmann
2006-08-29 20:04 ` Gerd Stolpmann
2006-08-30 0:44 ` malc
2006-08-30 0:53 ` Jonathan Roewen
2006-08-29 19:37 ` John Carr [this message]
2006-08-29 19:11 ` [Caml-list] " Eric Cooper
2006-08-30 6:12 ` Jeff Henrikson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200608291937.k7TJbfWP016413@contents-vnder-pressvre.mit.edu \
--to=jfc@mit.edu \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).