From owner-freebsd-bugs@FreeBSD.ORG Mon Sep 13 09:20:20 2004 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B882A16A4D2 for ; Mon, 13 Sep 2004 09:20:20 +0000 (GMT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8DADA43D31 for ; Mon, 13 Sep 2004 09:20:20 +0000 (GMT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.11/8.12.11) with ESMTP id i8D9KKCJ039142 for ; Mon, 13 Sep 2004 09:20:20 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.11/8.12.11/Submit) id i8D9KKT5039138; Mon, 13 Sep 2004 09:20:20 GMT (envelope-from gnats) Date: Mon, 13 Sep 2004 09:20:20 GMT Message-Id: <200409130920.i8D9KKT5039138@freefall.freebsd.org> To: freebsd-bugs@FreeBSD.org From: Giorgos Keramidas Subject: Re: bin/71623: [PATCH] cleanup of the usr.sbin/pcvt code X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Giorgos Keramidas List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Sep 2004 09:20:20 -0000 The following reply was made to PR bin/71623; it has been noted by GNATS. From: Giorgos Keramidas To: Dan Lukes Cc: bug-followup@freebsd.org Subject: Re: bin/71623: [PATCH] cleanup of the usr.sbin/pcvt code Date: Mon, 13 Sep 2004 12:10:54 +0300 On 2004-09-13 08:48, Dan Lukes wrote: > Giorgos Keramidas wrote: > >>>>! if (kbdc < 32) printf(" %s", ckeytab[(short int)kbdc].csymbol); > >>>Does the value really have to be a (short int) here? Wouldn't an (int) be > >>Because kbdc is type of char. Short int should be sufficient for char. > > > Apparently there's no special reason why this value should be > > `short' and not `int', so keeping the existing practice of using an > > `int' for holding a `char' value is what my suggestion was about. > > When sizes aren't equal then compiler must emit an conversion code. > > Well, I'm understand now that nobody here cares about a few bytes of > memory or tenths CPU ticks. Some of my programmesr skills came from > ancient days, so every byte and ticks seems to be valuable for me. But > no problem for me to adapt to todays programers practices ... ;-) > > If existing practice want int here we should use int. I'm far from the best person to ask for a definition of today's "canonical programming practice", but I'm trying to learn too. After reading parts of the FreeBSD source tree I've learned a tremendous amount of things and I still do learn every day. Influences by others are obvious too in the way I think and work though. One of the most influencial persons whose work I've admired is Donald E. Knuth, who has said: "We should forget about small efficiencies, say about 97% of the time: premature optimization is the root of all evil." -- Donald Knuth This is why I think that this sort of micro-optimizations are not worth a lot of trouble or time. Of course, this doesn't mean that I don't want you to keep improving the source of FreeBSD. I'm just vehemently opposed to optimizations done to tweak a machine-cycle here, a byte there, a single word of memory there, etc. by sacrifizing clarity, style and cleanness of the source or, for instance, by introducing dependencies to the way a specific compiler works. But I'm probably beginning to sound like an insufferable pedant. Off to a bit of hacking :) Regards, - Giorgos