From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dmitry Antipov Newsgroups: gmane.emacs.devel Subject: Use larger_vector instead of Fmake_vector and bcopy Date: Fri, 05 Oct 2007 13:12:24 +0400 Message-ID: <4705FFF8.20909@yandex.ru> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="------------080308000505060209050306" X-Trace: sea.gmane.org 1191576000 9432 80.91.229.12 (5 Oct 2007 09:20:00 GMT) X-Complaints-To: usenet@sea.gmane.org NNTP-Posting-Date: Fri, 5 Oct 2007 09:20:00 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Fri Oct 05 11:19:57 2007 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.50) id 1IdjLe-0001kH-TF for ged-emacs-devel@m.gmane.org; Fri, 05 Oct 2007 11:19:55 +0200 Original-Received: from localhost ([127.0.0.1] helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IdjLa-0004nH-4M for ged-emacs-devel@m.gmane.org; Fri, 05 Oct 2007 05:19:50 -0400 Original-Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IdjLV-0004mg-D2 for emacs-devel@gnu.org; Fri, 05 Oct 2007 05:19:45 -0400 Original-Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IdjLU-0004mT-03 for emacs-devel@gnu.org; Fri, 05 Oct 2007 05:19:44 -0400 Original-Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IdjLT-0004mQ-O5 for emacs-devel@gnu.org; Fri, 05 Oct 2007 05:19:43 -0400 Original-Received: from smtp4.yandex.ru ([213.180.223.136]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1IdjLT-0007oB-1X for emacs-devel@gnu.org; Fri, 05 Oct 2007 05:19:43 -0400 Original-Received: from rtsoft2.corbina.net ([85.21.88.2]:20618 "EHLO localhost.localdomain" smtp-auth: "dmantipov" TLS-CIPHER: TLS-PEER-CN1: ) by mail.yandex.ru with ESMTP id S738398AbXJEJTI (ORCPT ); Fri, 5 Oct 2007 13:19:08 +0400 X-Comment: RFC 2476 MSA function at smtp4.yandex.ru logged sender identity as: dmantipov User-Agent: Thunderbird 2.0.0.5 (X11/20070719) X-Detected-Kernel: Linux 2.6 (newer, 1) X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:80282 Archived-At: This is a multi-part message in MIME format. --------------080308000505060209050306 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Hello, this cleanup patch tries to utilize larger_vector instead of Fmake_vector & bcopy where possible, thus avoiding few code duplications. Dmitry --------------080308000505060209050306 Content-Type: text/x-patch; name="larger_vector.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="larger_vector.patch" Index: ChangeLog =================================================================== RCS file: /sources/emacs/emacs/src/ChangeLog,v retrieving revision 1.5912 diff -u -r1.5912 ChangeLog --- ChangeLog 4 Oct 2007 16:57:53 -0000 1.5912 +++ ChangeLog 5 Oct 2007 05:28:13 -0000 @@ -1,3 +1,14 @@ +2007-10-05 Dmitry Antipov + + * buffer.c (add_overlay_mod_hooklist): + * ccl.c (Fregister_ccl_program, Fregister_code_conversion_map): + * fontset.c (make_fontset): + * keyboard.c (GROW_RAW_KEYBUF, menu_bar_items, menu_bar_item) + (append_tool_bar_item): + * macmenu.c (grow_menu_items): + * w32menu.c (grow_menu_items): + * xmenu.c (grow_menu_items): use larger_vector. + 2007-10-04 Juanma Barranquero * image.c (syms_of_image) : Fix typo in docstring. Index: buffer.c =================================================================== RCS file: /sources/emacs/emacs/src/buffer.c,v retrieving revision 1.534 diff -u -r1.534 buffer.c --- buffer.c 2 Oct 2007 21:09:17 -0000 1.534 +++ buffer.c 5 Oct 2007 05:28:13 -0000 @@ -4217,15 +4217,8 @@ int oldsize = XVECTOR (last_overlay_modification_hooks)->size; if (last_overlay_modification_hooks_used == oldsize) - { - Lisp_Object old; - old = last_overlay_modification_hooks; - last_overlay_modification_hooks - = Fmake_vector (make_number (oldsize * 2), Qnil); - bcopy (XVECTOR (old)->contents, - XVECTOR (last_overlay_modification_hooks)->contents, - sizeof (Lisp_Object) * oldsize); - } + last_overlay_modification_hooks = larger_vector + (last_overlay_modification_hooks, oldsize * 2, Qnil); AREF (last_overlay_modification_hooks, last_overlay_modification_hooks_used++) = functionlist; AREF (last_overlay_modification_hooks, last_overlay_modification_hooks_used++) = overlay; } Index: ccl.c =================================================================== RCS file: /sources/emacs/emacs/src/ccl.c,v retrieving revision 1.99 diff -u -r1.99 ccl.c --- ccl.c 13 Aug 2007 13:41:13 -0000 1.99 +++ ccl.c 5 Oct 2007 05:28:13 -0000 @@ -2348,16 +2348,8 @@ } if (idx == len) - { - /* Extend the table. */ - Lisp_Object new_table; - int j; - - new_table = Fmake_vector (make_number (len * 2), Qnil); - for (j = 0; j < len; j++) - ASET (new_table, j, AREF (Vccl_program_table, j)); - Vccl_program_table = new_table; - } + /* Extend the table. */ + Vccl_program_table = larger_vector (Vccl_program_table, len * 2, Qnil); { Lisp_Object elt; @@ -2416,15 +2408,8 @@ } if (i == len) - { - Lisp_Object new_vector = Fmake_vector (make_number (len * 2), Qnil); - int j; - - for (j = 0; j < len; j++) - AREF (new_vector, j) - = AREF (Vcode_conversion_map_vector, j); - Vcode_conversion_map_vector = new_vector; - } + Vcode_conversion_map_vector = larger_vector + (Vcode_conversion_map_vector, len * 2, Qnil); index = make_number (i); Fput (symbol, Qcode_conversion_map, map); Index: fontset.c =================================================================== RCS file: /sources/emacs/emacs/src/fontset.c,v retrieving revision 1.107 diff -u -r1.107 fontset.c --- fontset.c 29 Aug 2007 05:27:55 -0000 1.107 +++ fontset.c 5 Oct 2007 05:28:13 -0000 @@ -391,15 +391,7 @@ while (!NILP (AREF (Vfontset_table, id))) id++; if (id + 1 == size) - { - Lisp_Object tem; - int i; - - tem = Fmake_vector (make_number (size + 8), Qnil); - for (i = 0; i < size; i++) - AREF (tem, i) = AREF (Vfontset_table, i); - Vfontset_table = tem; - } + Vfontset_table = larger_vector (Vfontset_table, size + 8, Qnil); fontset = Fmake_char_table (Qfontset, Qnil); Index: keyboard.c =================================================================== RCS file: /sources/emacs/emacs/src/keyboard.c,v retrieving revision 1.916 diff -u -r1.916 keyboard.c --- keyboard.c 23 Sep 2007 02:02:42 -0000 1.916 +++ keyboard.c 5 Oct 2007 05:28:14 -0000 @@ -160,14 +160,7 @@ #define GROW_RAW_KEYBUF \ if (raw_keybuf_count == XVECTOR (raw_keybuf)->size) \ - { \ - int newsize = 2 * XVECTOR (raw_keybuf)->size; \ - Lisp_Object new; \ - new = Fmake_vector (make_number (newsize), Qnil); \ - bcopy (XVECTOR (raw_keybuf)->contents, XVECTOR (new)->contents, \ - raw_keybuf_count * sizeof (Lisp_Object)); \ - raw_keybuf = new; \ - } + raw_keybuf = larger_vector (raw_keybuf, raw_keybuf_count * 2, Qnil) \ /* Number of elements of this_command_keys that precede this key sequence. */ @@ -7588,13 +7581,7 @@ /* Add nil, nil, nil, nil at the end. */ i = menu_bar_items_index; if (i + 4 > XVECTOR (menu_bar_items_vector)->size) - { - Lisp_Object tem; - tem = Fmake_vector (make_number (2 * i), Qnil); - bcopy (XVECTOR (menu_bar_items_vector)->contents, - XVECTOR (tem)->contents, i * sizeof (Lisp_Object)); - menu_bar_items_vector = tem; - } + menu_bar_items_vector = larger_vector (menu_bar_items_vector, 2 * i, Qnil); /* Add this item. */ XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil; XVECTOR (menu_bar_items_vector)->contents[i++] = Qnil; @@ -7666,14 +7653,7 @@ { /* If vector is too small, get a bigger one. */ if (i + 4 > XVECTOR (menu_bar_items_vector)->size) - { - Lisp_Object tem; - tem = Fmake_vector (make_number (2 * i), Qnil); - bcopy (XVECTOR (menu_bar_items_vector)->contents, - XVECTOR (tem)->contents, i * sizeof (Lisp_Object)); - menu_bar_items_vector = tem; - } - + menu_bar_items_vector = larger_vector (menu_bar_items_vector, 2 * i, Qnil); /* Add this item. */ XVECTOR (menu_bar_items_vector)->contents[i++] = key; XVECTOR (menu_bar_items_vector)->contents[i++] @@ -8442,16 +8422,8 @@ /* Enlarge tool_bar_items_vector if necessary. */ if (ntool_bar_items + TOOL_BAR_ITEM_NSLOTS >= XVECTOR (tool_bar_items_vector)->size) - { - Lisp_Object new_vector; - int old_size = XVECTOR (tool_bar_items_vector)->size; - - new_vector = Fmake_vector (make_number (2 * old_size), Qnil); - bcopy (XVECTOR (tool_bar_items_vector)->contents, - XVECTOR (new_vector)->contents, - old_size * sizeof (Lisp_Object)); - tool_bar_items_vector = new_vector; - } + tool_bar_items_vector = larger_vector + (tool_bar_items_vector, 2 * XVECTOR (tool_bar_items_vector)->size, Qnil); /* Append entries from tool_bar_item_properties to the end of tool_bar_items_vector. */ Index: macmenu.c =================================================================== RCS file: /sources/emacs/emacs/src/macmenu.c,v retrieving revision 1.64 diff -u -r1.64 macmenu.c --- macmenu.c 29 Aug 2007 05:27:54 -0000 1.64 +++ macmenu.c 5 Oct 2007 05:28:14 -0000 @@ -347,15 +347,8 @@ static void grow_menu_items () { - Lisp_Object old; - int old_size = menu_items_allocated; - old = menu_items; - menu_items_allocated *= 2; - - menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); - bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents, - old_size * sizeof (Lisp_Object)); + menu_items = larger_vector (menu_items, menu_items_allocated, Qnil); } /* Begin a submenu. */ Index: w32menu.c =================================================================== RCS file: /sources/emacs/emacs/src/w32menu.c,v retrieving revision 1.92 diff -u -r1.92 w32menu.c --- w32menu.c 29 Aug 2007 05:27:57 -0000 1.92 +++ w32menu.c 5 Oct 2007 05:28:14 -0000 @@ -318,14 +318,8 @@ static void grow_menu_items () { - Lisp_Object old; - int old_size = menu_items_allocated; - old = menu_items; - menu_items_allocated *= 2; - menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); - bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents, - old_size * sizeof (Lisp_Object)); + menu_items = larger_vector (menu_items, menu_items_allocated, Qnil); } /* Begin a submenu. */ Index: xmenu.c =================================================================== RCS file: /sources/emacs/emacs/src/xmenu.c,v retrieving revision 1.323 diff -u -r1.323 xmenu.c --- xmenu.c 12 Sep 2007 07:23:12 -0000 1.323 +++ xmenu.c 5 Oct 2007 05:28:14 -0000 @@ -354,15 +354,8 @@ static void grow_menu_items () { - Lisp_Object old; - int old_size = menu_items_allocated; - old = menu_items; - menu_items_allocated *= 2; - - menu_items = Fmake_vector (make_number (menu_items_allocated), Qnil); - bcopy (XVECTOR (old)->contents, XVECTOR (menu_items)->contents, - old_size * sizeof (Lisp_Object)); + menu_items = larger_vector (menu_items, menu_items_allocated, Qnil); } /* Begin a submenu. */ --------------080308000505060209050306 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://lists.gnu.org/mailman/listinfo/emacs-devel --------------080308000505060209050306--