From mboxrd@z Thu Jan 1 00:00:00 1970 MIME-Version: 1.0 In-Reply-To: <20110406163229.6A159B84A@mail.bitblocks.com> References: <86fwpz55nj.fsf@cmarib.ramside> <257867.782e4d7b.wsc0.mx@tumtum.plumbweb.net> <5ddd9deccbea5e8556dfc0c228b63311@ladd.quanstro.net> <86vcythf8h.fsf@cmarib.ramside> <14A00924-1B1B-4169-B520-80A11D3F098B@fastmail.fm> <20110406163229.6A159B84A@mail.bitblocks.com> Date: Wed, 6 Apr 2011 17:43:36 +0100 Message-ID: From: roger peppe To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [9fans] Making read(1) an rc(1) builtin? Topicbox-Message-UUID: cc15482e-ead6-11e9-9d60-3106f5b1d025 On 6 April 2011 17:32, Bakul Shah wrote: > On Tue, 05 Apr 2011 15:53:43 MDT andrey mirtchovski =C2=A0wrote: >> so, an optimized /sys/src/cmd/read.c that doesn't read char-by-char >> should give us an improvement, right? right: >> 9grid% newaread >> 1.52u 22.56s 15.66r =C2=A0 =C2=A0newaread >> >> and that's just for the silly "test" string. the improvement would be >> bigger for longer strings. > > read(1) is allowed to read one line and no more. Given a read > of > 1 char, a console device will return a line at most but > other devices can return more than one line, thereby > preventing the next guy from reading it. =C2=A0read(1) has to read > one char at a time. > > With a builtin read you don't pay the cost of a fork/exec per > char. =C2=A0And it would be less clunky -- instead of "foo=3D`{read}" > you can say "read foo". =C2=A0It is not like rc going to get fat by > adding read; it already has to read! a builtin read would still have to read one character at a time though.