From patchwork Mon Apr 11 17:09:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicola Pero X-Patchwork-Id: 90628 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 63F38B6F14 for ; Tue, 12 Apr 2011 03:10:00 +1000 (EST) Received: (qmail 5445 invoked by alias); 11 Apr 2011 17:09:58 -0000 Received: (qmail 5436 invoked by uid 22791); 11 Apr 2011 17:09:56 -0000 X-SWARE-Spam-Status: No, hits=-0.3 required=5.0 tests=AWL, BAYES_00, FSL_RU_URL, TW_BJ, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from fencepost.gnu.org (HELO fencepost.gnu.org) (140.186.70.10) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 11 Apr 2011 17:09:50 +0000 Received: from eggs.gnu.org ([140.186.70.92]:58495) by fencepost.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1Q9KcW-00028g-Br for gcc-patches@gnu.org; Mon, 11 Apr 2011 13:09:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Q9KcU-0006rV-VP for gcc-patches@gnu.org; Mon, 11 Apr 2011 13:09:47 -0400 Received: from smtp111.iad.emailsrvr.com ([207.97.245.111]:32834) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Q9KcU-0006ql-Re for gcc-patches@gnu.org; Mon, 11 Apr 2011 13:09:46 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp41.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id 110EF2915E4 for ; Mon, 11 Apr 2011 13:09:46 -0400 (EDT) Received: from dynamic5.wm-web.iad.mlsrvr.com (dynamic5.wm-web.iad1a.rsapps.net [192.168.2.146]) by smtp41.relay.iad1a.emailsrvr.com (SMTP Server) with ESMTP id F255F2914EF for ; Mon, 11 Apr 2011 13:09:45 -0400 (EDT) Received: from meta-innovation.com (localhost [127.0.0.1]) by dynamic5.wm-web.iad.mlsrvr.com (Postfix) with ESMTP id A29378D0BC1 for ; Mon, 11 Apr 2011 13:09:45 -0400 (EDT) Received: by www2.webmail.us (Authenticated sender: nicola.pero@meta-innovation.com, from: nicola.pero@meta-innovation.com) with HTTP; Mon, 11 Apr 2011 19:09:45 +0200 (CEST) Date: Mon, 11 Apr 2011 19:09:45 +0200 (CEST) Subject: ObjC: some minor optimizations From: "Nicola Pero" To: "gcc-patches@gnu.org" MIME-Version: 1.0 X-Type: plain Message-ID: <1302541785.662131434@192.168.4.58> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 207.97.245.111 X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org This patch removes some very minor inefficiencies in the ObjC compiler code. Ok to commit ? Thanks Index: gcc/objc/ChangeLog =================================================================== --- gcc/objc/ChangeLog (revision 172239) +++ gcc/objc/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2011-04-10 Nicola Pero + + * objc-act.c (objc_is_class_name, objc_is_id): For efficiency, + avoid calling identifier_global_value() multiple times. + 2011-04-06 Joseph Myers * objc-act.c: Include c-target.h instead of target.h. Index: gcc/objc/objc-act.c =================================================================== --- gcc/objc/objc-act.c (revision 172239) +++ gcc/objc/objc-act.c (working copy) @@ -3411,9 +3411,13 @@ objc_is_class_name (tree ident) { hash target; - if (ident && TREE_CODE (ident) == IDENTIFIER_NODE - && identifier_global_value (ident)) - ident = identifier_global_value (ident); + if (ident && TREE_CODE (ident) == IDENTIFIER_NODE) + { + tree t = identifier_global_value (ident); + if (t) + ident = t; + } + while (ident && TREE_CODE (ident) == TYPE_DECL && DECL_ORIGINAL_TYPE (ident)) ident = OBJC_TYPE_NAME (DECL_ORIGINAL_TYPE (ident)); @@ -3453,9 +3457,12 @@ objc_is_class_name (tree ident) tree objc_is_id (tree type) { - if (type && TREE_CODE (type) == IDENTIFIER_NODE - && identifier_global_value (type)) - type = identifier_global_value (type); + if (type && TREE_CODE (type) == IDENTIFIER_NODE) + { + tree t = identifier_global_value (type); + if (t) + type = t; + } if (type && TREE_CODE (type) == TYPE_DECL) type = TREE_TYPE (type); Index: gcc/ChangeLog =================================================================== --- gcc/ChangeLog (revision 172239) +++ gcc/ChangeLog (working copy) @@ -1,3 +1,8 @@ +2011-04-10 Nicola Pero + + * c-parser.c (c_lex_one_token): Rewritten conditional used when + compiling Objective-C to be more efficient. + 2011-04-09 Anatoly Sokolov * expr.c (expand_expr_real_1): Use add_to_hard_reg_set function Index: gcc/c-parser.c =================================================================== --- gcc/c-parser.c (revision 172239) +++ gcc/c-parser.c (working copy) @@ -334,8 +334,7 @@ c_lex_one_token (c_parser *parser, c_token *token) variables and typedefs, and hence are shadowed by local declarations. */ if (objc_interface_decl - && (global_bindings_p () - || (!objc_force_identifier && !decl))) + && (!objc_force_identifier || global_bindings_p ())) { token->value = objc_interface_decl; token->id_kind = C_ID_CLASSNAME;