From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10389 invoked by alias); 7 Dec 2007 23:11:48 -0000 Received: (qmail 10370 invoked by uid 22791); 7 Dec 2007 23:11:47 -0000 X-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,DK_POLICY_SIGNSOME,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 07 Dec 2007 23:11:43 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.13.8/8.13.1) with ESMTP id lB7NBfq8030429 for ; Fri, 7 Dec 2007 18:11:41 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [10.11.255.20]) by int-mx1.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lB7NBfJC002327 for ; Fri, 7 Dec 2007 18:11:41 -0500 Received: from [127.0.0.1] (sebastian-int.corp.redhat.com [172.16.52.221]) by pobox.corp.redhat.com (8.13.1/8.13.1) with ESMTP id lB7NBeUM000703; Fri, 7 Dec 2007 18:11:40 -0500 Message-ID: <4759D33D.5050206@redhat.com> Date: Fri, 07 Dec 2007 23:11:00 -0000 From: Andrew Cagney User-Agent: Thunderbird 1.5.0.12 (X11/20070530) MIME-Version: 1.0 To: Stan Cox CC: Frysk List Subject: Re: Use StringBuilder instead of PrintWriter for type display References: <1197063360.10805.165.camel@multics.rdu.redhat.com> In-Reply-To: <1197063360.10805.165.camel@multics.rdu.redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact frysk-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: frysk-owner@sourceware.org X-SW-Source: 2007-q4/txt/msg00213.txt.bz2 Stan Cox wrote: > This changes type display so it builds in a StringBuilder > instead of displaying a piece at a time. Most of the changes are > changing writer.print to stringBuilder.append. A printf style %s token > is used to support types like > "int (*ptr_arr) [4]" where (in this instance) the name and pointer > info have to be inserted a printf %s string is used. For instance > ArrayType would construct "int %s [4]" and then PointerType would > massage that to "int (*%s) [4] and if it is member of a struct > CompositeType would massage it to "int (*ptr_arr) [4]" (otherwise "int > (*) [4]). This allows removal of some instanceof checks and some > specialized code. > Yes, the result is much better. Would a specialized class help: instead of a SingleString buffer, it would contain the prefix and postfix strings, and methods to edit them. For instance, given: struct s { (*foo)[10]; } ArrayType would .append("[10]"); called by PointerType would .insert("(*", ")"); called by CompositeType would .insert("foo"); Andrew