From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KNCIa-0001ty-N5 for mharc-grub-devel@gnu.org; Sun, 27 Jul 2008 15:52:56 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KNCIZ-0001tl-5r for grub-devel@gnu.org; Sun, 27 Jul 2008 15:52:55 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KNCIR-0001tJ-HG for grub-devel@gnu.org; Sun, 27 Jul 2008 15:52:54 -0400 Received: from [199.232.76.173] (port=38800 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KNCIR-0001tG-EX for grub-devel@gnu.org; Sun, 27 Jul 2008 15:52:47 -0400 Received: from gateway02.websitewelcome.com ([69.93.115.20]:33374) by monty-python.gnu.org with smtp (Exim 4.60) (envelope-from ) id 1KNCIR-0007vc-6R for grub-devel@gnu.org; Sun, 27 Jul 2008 15:52:47 -0400 Received: (qmail 24072 invoked from network); 27 Jul 2008 20:05:38 -0000 Received: from gator297.hostgator.com (74.53.228.114) by gateway02.websitewelcome.com with SMTP; 27 Jul 2008 20:05:38 -0000 Received: from c-67-185-142-228.hsd1.wa.comcast.net ([67.185.142.228]:35982 helo=localhost) by gator297.hostgator.com with esmtpsa (TLSv1:AES128-SHA:128) (Exim 4.68) (envelope-from ) id 1KNCIL-0008Mv-HR; Sun, 27 Jul 2008 14:52:41 -0500 Date: Sun, 27 Jul 2008 12:51:54 -0700 From: Colin D Bennett To: The development of GRUB 2 Message-ID: <20080727125154.1ffb69b6@gibibit.com> In-Reply-To: References: X-Mailer: Claws Mail 3.5.0 (GTK+ 2.12.10; i686-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator297.hostgator.com X-AntiAbuse: Original Domain - gnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - gibibit.com X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 3) Cc: bean123ch@gmail.com Subject: Re: [PATCH] buffered file read X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 27 Jul 2008 19:52:55 -0000 On Mon, 28 Jul 2008 01:52:40 +0800 Bean wrote: > Hi, > > This patch add a new module bufio, which reads block of data at a > time, and return the required range to the upper level. This is > extremely useful in modules like png, where data are normally read one > byte at a time. > > To use buffered io service, just include header file , > and replace grub_file_open with grub_buffile_open. > > Changelog: > > 2008-07-27 Bean > > * conf/common.rmk (pkglib_MODULES): Add bufio.mod. > (bufio_mod_SOURCES): New macro. > (bufio_mod_CFLAGS): Likewise. > (bufio_mod_LDFLAGS): Likewise. > > * include/grub/bufio.h: New file. > > * io/bufio.c: Likewise. > > * video/png.c (grub_video_reader_png): Use grub_buffile_open > to open file. > > * video/jpeg.c (grub_video_reader_jpeg): Likewise. > > * video/tga.c (grub_video_reader_tga): Likewise. Hi Bean, Beautiful code! Thanks so much for doing this work -- using buffered file reads is absolutely necessary from a performance perspective, and I am glad to see it implemented so cleanly. My poor hack of grub_file_read() bows to your far superior patch! I really appreciate the simplicity and clarity of both its design and its use. I like how you implemented it using the Decorator pattern (from the GoF design patterns) to wrap the basic file with the buffered file layer in a way transparent to users. This is very intuitive to me, especially since Java does exactly the same thing with InputStream and BufferedInputStream. The best part is that users of file I/O only have to change one function call to get all the benefits of the buffering. I will begin testing with this patch instead of mine shortly. Thanks again! Regards, Colin