From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26930 invoked by alias); 21 Jul 2009 17:57:56 -0000 Received: (qmail 26920 invoked by uid 22791); 21 Jul 2009 17:57:55 -0000 X-SWARE-Spam-Status: No, hits=-2.3 required=5.0 tests=AWL,BAYES_00,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 21 Jul 2009 17:57:45 +0000 Received: (qmail 28567 invoked from network); 21 Jul 2009 17:57:43 -0000 Received: from unknown (HELO macbook-2.local) (stan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 21 Jul 2009 17:57:43 -0000 Message-ID: <4A660190.3080407@codesourcery.com> Date: Tue, 21 Jul 2009 18:08:00 -0000 From: Stan Shebs User-Agent: Thunderbird 2.0.0.22 (Macintosh/20090605) MIME-Version: 1.0 To: tromey@redhat.com CC: Michael Snyder , "gdb-patches@sourceware.org" Subject: Re: [RFA] clean up temp sals in handle_inferior_event References: <4A63D5B4.8090505@vmware.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2009-07/txt/msg00516.txt.bz2 Tom Tromey wrote: >>>>>> "Michael" == Michael Snyder writes: >>>>>> > > Michael> There were seven, and now eight, places in handle_inferior_event > Michael> where a local struct symtab_and_line is declared and used briefly. > Michael> One of them even opens and closes a block just for this purpose. > > Michael> This patch merges those all into a single local temp variable. > > Michael> They all initialize it, and all but one of them returns after > Michael> using it, so they can't interact. Plus I ran the testsuites > Michael> with no regressions. > > I find the old code clearer. In the old code, these temporary variables > are mostly declared in small blocks surrounding their point of use. > This means that it is very easy to reason about the variable: its entire > lifetime fits onto the screen at once. > I'd find it easier debuggingwise to have fewer of the small scopes, *but* to give the sals different names indicating their roles. For me the confusion comes from using a single variable name in a function to mean several different things, whether or not each is in a different scope. Stan