all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* Redundant type checking in window.c and w32menu.c
@ 2007-06-19 14:44 Dmitry Antipov
  2007-06-19 14:55 ` Stefan Monnier
  2007-06-19 18:46 ` Ken Raeburn
  0 siblings, 2 replies; 10+ messages in thread
From: Dmitry Antipov @ 2007-06-19 14:44 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 649 bytes --]

If we pass CHECK_CONS(), we don't need CONSP()s in Fcar() and Fcdr() and may use XCAR()
and XCDR() instead.

Dmitry

P.S. Is code size the only reason to call Fcar(), Fcdr() and their safe versions directly
from C code ? Replacing these dumb proxies with an appropriate macros eliminates a lot of
function calls at the cost of ~28K increment in code size (for a stripped binary on x86).
Note if someone needs smaller emacs executable (what a strange requirement, but why not ?),
just replacing -O2 with -Os saves ~235K.

P.P.S. Maintainers, please update my e-mail to dmantipov@yandex.ru in src/ChangeLog -
dmitry.antipov@mail.ru is no longer used.

[-- Attachment #2: omit_redundant_type_check.patch --]
[-- Type: text/plain, Size: 1098 bytes --]

Index: window.c
===================================================================
RCS file: /sources/emacs/emacs/src/window.c,v
retrieving revision 1.577
diff -u -r1.577 window.c
--- window.c	1 Jun 2007 10:57:37 -0000	1.577
+++ window.c	19 Jun 2007 14:05:32 -0000
@@ -942,8 +942,8 @@
   w = XWINDOW (window);
   f = XFRAME (w->frame);
   CHECK_CONS (coordinates);
-  lx = Fcar (coordinates);
-  ly = Fcdr (coordinates);
+  lx = XCAR (coordinates);
+  ly = XCDR (coordinates);
   CHECK_NUMBER_OR_FLOAT (lx);
   CHECK_NUMBER_OR_FLOAT (ly);
   x = FRAME_PIXEL_X_FROM_CANON_X (f, lx) + FRAME_INTERNAL_BORDER_WIDTH (f);
Index: w32menu.c
===================================================================
RCS file: /sources/emacs/emacs/src/w32menu.c,v
retrieving revision 1.90
diff -u -r1.90 w32menu.c
--- w32menu.c	17 Jun 2007 22:10:06 -0000	1.90
+++ w32menu.c	19 Jun 2007 14:05:32 -0000
@@ -605,7 +605,7 @@
       else
 	{
 	  CHECK_CONS (item);
-	  item1 = Fcar (item);
+	  item1 = XCAR (item);
 	  CHECK_STRING (item1);
 	  push_menu_item (item1, Qt, Fcdr (item), Qt, Qnil, Qnil, Qnil, Qnil);
 	}

[-- Attachment #3: Type: text/plain, Size: 142 bytes --]

_______________________________________________
Emacs-devel mailing list
Emacs-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/emacs-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2007-06-21 17:38 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-06-19 14:44 Redundant type checking in window.c and w32menu.c Dmitry Antipov
2007-06-19 14:55 ` Stefan Monnier
2007-06-19 18:46 ` Ken Raeburn
2007-06-20 14:12   ` Dmitry Antipov
2007-06-20 15:20     ` Jason Rumney
2007-06-20 17:55       ` dmantipov
2007-06-20 20:46         ` Jason Rumney
2007-06-21 15:46           ` Dmitry Antipov
2007-06-21 17:38           ` Ken Raeburn
2007-06-20 20:12     ` Tom Tromey

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.