From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Spencer Baugh Newsgroups: gmane.emacs.devel Subject: [PATCH v2 07/16] Take offset not idx in PER_BUFFER_VALUE_P Date: Sat, 21 Nov 2020 21:34:36 -0500 Message-ID: References: <20201119153814.17541-1-sbaugh@catern.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38263"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Spencer Baugh , Arnold Noronha , Stefan Monnier , Dmitry Gutov To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Nov 22 03:42:10 2020 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kgfKK-0009qU-Rz for ged-emacs-devel@m.gmane-mx.org; Sun, 22 Nov 2020 03:42:08 +0100 Original-Received: from localhost ([::1]:58582 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kgfKJ-0000Ui-Qb for ged-emacs-devel@m.gmane-mx.org; Sat, 21 Nov 2020 21:42:07 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:40968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgfDL-0000Nn-ND for emacs-devel@gnu.org; Sat, 21 Nov 2020 21:34:55 -0500 Original-Received: from venus.catern.com ([68.183.49.163]:60146) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kgfDI-0007J7-HM for emacs-devel@gnu.org; Sat, 21 Nov 2020 21:34:55 -0500 Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=98.7.229.235; helo=localhost; envelope-from=sbaugh@catern.com; receiver= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=catern.com; s=mail; t=1606012491; bh=6xz6zBS0XcdlXifMuFD4kMekh4S+MWrBebHsaEy6o7w=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=QVQ9rW75L+RPvwRSsr25naIzx4amu7YlcPT2Z0mM0U2xOMmMn/k6q2hQbvNcc/kV9 hJH2C9rg7AGaZV3rg7yWEohdzgJZbxdhNGR1l2KC5D/dcjh7nzd1x3engFvQA6vIef gzop4Aglb9KrOrNViEno3oxHDutHVR1HIS94fi8A= Original-Received: from localhost (cpe-98-7-229-235.nyc.res.rr.com [98.7.229.235]) by venus.catern.com (Postfix) with ESMTPSA id DCE112DDDCA; Sun, 22 Nov 2020 02:34:51 +0000 (UTC) X-Mailer: git-send-email 2.28.0 In-Reply-To: Received-SPF: pass client-ip=68.183.49.163; envelope-from=sbaugh@catern.com; helo=venus.catern.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:259582 Archived-At: This also moves the common "idx == -1" check into PER_BUFFER_VALUE_P. If idx == -1, it's guaranteed that the corresponding buffer field has a per-buffer value. We do this check everywhere we call PER_BUFFER_VALUE_P, so let's put it in the common code. This is motivated by later commits which will get rid of idx. --- src/buffer.c | 3 +-- src/buffer.h | 21 +++++++++++---------- src/data.c | 11 +++++------ 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index aa951ca78f..a0bcbf38e5 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1297,8 +1297,7 @@ buffer_lisp_local_variables (struct buffer *buf, bool clone) static Lisp_Object buffer_local_variables_1 (struct buffer *buf, int offset, Lisp_Object sym) { - int idx = PER_BUFFER_IDX (offset); - if ((idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) + if (PER_BUFFER_VALUE_P (buf, offset) && SYMBOLP (PER_BUFFER_SYMBOL (offset))) { sym = NILP (sym) ? PER_BUFFER_SYMBOL (offset) : sym; diff --git a/src/buffer.h b/src/buffer.h index 770a5d03e6..69df791b53 100644 --- a/src/buffer.h +++ b/src/buffer.h @@ -1420,16 +1420,6 @@ OVERLAY_POSITION (Lisp_Object p) extern bool valid_per_buffer_idx (int); -/* Value is true if the variable with index IDX has a local value - in buffer B. */ - -INLINE bool -PER_BUFFER_VALUE_P (struct buffer *b, int idx) -{ - eassert (valid_per_buffer_idx (idx)); - return b->local_flags[idx]; -} - /* Set whether per-buffer variable with index IDX has a buffer-local value in buffer B. VAL zero means it hasn't. */ @@ -1496,6 +1486,17 @@ set_per_buffer_value (struct buffer *b, int offset, Lisp_Object value) *(Lisp_Object *)(offset + (char *) b) = value; } +/* Value is true if the variable with offset OFFSET has a local value + in buffer B. */ + +INLINE bool +PER_BUFFER_VALUE_P (struct buffer *b, int offset) +{ + int idx = PER_BUFFER_IDX (offset); + eassert (idx == -1 || valid_per_buffer_idx (idx)); + return idx == -1 || b->local_flags[idx]; +} + /* Downcase a character C, or make no change if that cannot be done. */ INLINE int downcase (int c) diff --git a/src/data.c b/src/data.c index 384c259220..47a1a6640f 100644 --- a/src/data.c +++ b/src/data.c @@ -1123,7 +1123,7 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval, { struct buffer *b = XBUFFER (buf); - if (! PER_BUFFER_VALUE_P (b, idx)) + if (! PER_BUFFER_VALUE_P (b, offset)) set_per_buffer_value (b, offset, newval); } } @@ -1440,8 +1440,8 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, { int offset = XBUFFER_OBJFWD (innercontents)->offset; int idx = PER_BUFFER_IDX (offset); - if (idx > 0 && bindflag == SET_INTERNAL_SET - && !PER_BUFFER_VALUE_P (buf, idx)) + if (bindflag == SET_INTERNAL_SET + && !PER_BUFFER_VALUE_P (buf, offset)) { if (let_shadows_buffer_binding_p (sym)) set_default_internal (symbol, newval, bindflag); @@ -1740,7 +1740,7 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value, { struct buffer *b = XBUFFER (buf); - if (!PER_BUFFER_VALUE_P (b, idx)) + if (!PER_BUFFER_VALUE_P (b, offset)) set_per_buffer_value (b, offset, value); } } @@ -2077,8 +2077,7 @@ BUFFER defaults to the current buffer. */) if (BUFFER_OBJFWDP (valcontents)) { int offset = XBUFFER_OBJFWD (valcontents)->offset; - int idx = PER_BUFFER_IDX (offset); - if (idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) + if (PER_BUFFER_VALUE_P (buf, offset)) return Qt; } return Qnil; -- 2.28.0