[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
pkg 4f7c171fb4 49/76: Support specifying package size
From: |
Gerd Moellmann |
Subject: |
pkg 4f7c171fb4 49/76: Support specifying package size |
Date: |
Fri, 21 Oct 2022 00:16:13 -0400 (EDT) |
branch: pkg
commit 4f7c171fb4eae8b88f5f7483cefad2a48e1923a3
Author: Gerd Möllmann <gerd@gnu.org>
Commit: Gerd Möllmann <gerd@gnu.org>
Support specifying package size
---
src/pkg.c | 34 +++++++++++++++++++++-------------
1 file changed, 21 insertions(+), 13 deletions(-)
diff --git a/src/pkg.c b/src/pkg.c
index 3d0bb01672..04b5607306 100644
--- a/src/pkg.c
+++ b/src/pkg.c
@@ -166,20 +166,22 @@ symbols_to_list (Lisp_Object thing)
}
/* Create and return a new Lisp package object for a package with name
- NAME, a string.
-
- What are the contents of the symbol hash table? Mapping symbol
- names to entries of which form? Can there be more than one
- symbol-name for different symbols */
+ NAME, a string. NSYMBOLS is the expected number of symbols. */
static Lisp_Object
-make_package (Lisp_Object name)
+make_package (Lisp_Object name, Lisp_Object nsymbols)
{
- struct Lisp_Package *pkg
- = ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Package, symbols,
PVEC_PACKAGE);
eassert (STRINGP (name));
+ if (NILP (nsymbols))
+ nsymbols = make_fixnum (50);
+ CHECK_FIXNAT (nsymbols);
+
+ struct Lisp_Package *pkg
+ = ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Package, symbols,
+ PVEC_PACKAGE);
pkg->name = name;
- pkg->symbols = CALLN (Fmake_hash_table, QCtest, Qequal, QCsize, make_fixnum
(1024));
+ pkg->symbols = CALLN (Fmake_hash_table, QCtest, Qequal,
+ QCsize, nsymbols);
Lisp_Object package;
XSETPACKAGE (package, pkg);
@@ -683,7 +685,7 @@ fake_me_an_obarray (Lisp_Object vector)
Lisp_Object package = Faref (vector, make_fixnum (0));
if (!PACKAGEP (package))
{
- package = make_package (build_string ("fake obarray"));
+ package = make_package (build_string ("fake obarray"), Qnil);
Faset (vector, make_fixnum (0), package);
}
return package;
@@ -939,12 +941,16 @@ usage: (make-package NAME &rest KEYWORD-ARGS) */)
const Lisp_Object nickname_designators = nicknames_index ?
args[nicknames_index] : Qnil;
const Lisp_Object nicknames = string_list_from_designators
(nickname_designators);
+ /* Check for :SIZE. Argument is checked in make_package. */
+ const ptrdiff_t size_index = get_key_arg (QCsize, nargs, args, used_args);
+ const Lisp_Object size = size_index ? args[size_index] : Qnil;
+
/* Now, all args should have been used up, or there's a problem. */
for (ptrdiff_t i = 0; i < nargs; ++i)
if (!used_args[i])
signal_error ("make-package: invalid argument", args[i]);
- const Lisp_Object package = make_package (name);
+ const Lisp_Object package = make_package (name, size);
XPACKAGE (package)->nicknames = nicknames;
XPACKAGE (package)->used_packages = used_packages;
@@ -1243,9 +1249,11 @@ init_pkg_once (void)
DEFAULT_REHASH_THRESHOLD,
Qnil, false);
- Vemacs_package = make_package (build_string ("emacs"));
+ Vemacs_package = make_package (build_string ("emacs"),
+ make_fixnum (20000));
staticpro (&Vemacs_package);
- Vkeyword_package = make_package (build_string ("keyword"));
+ Vkeyword_package = make_package (build_string ("keyword"),
+ make_fixnum (2000));
register_package (Vemacs_package);
staticpro (&Vkeyword_package);
- pkg 62582ea927 72/76: Fix completion for new symbol table layout, (continued)
- pkg 62582ea927 72/76: Fix completion for new symbol table layout, Gerd Moellmann, 2022/10/21
- pkg a93ec52542 76/76: Work on Lisp interface, Gerd Moellmann, 2022/10/21
- pkg 9ab00f542f 70/76: Introduce PACKAGE_NAMEX, Gerd Moellmann, 2022/10/21
- pkg 51cd0e05d6 71/76: De-duplicate packages for mapatoms, Gerd Moellmann, 2022/10/21
- pkg 9a263a0782 57/76: Move more package stuff to Lisp, Gerd Moellmann, 2022/10/21
- pkg d374cb202a 43/76: Revert "Use make-package instead of make-vector", Gerd Moellmann, 2022/10/21
- pkg 77543a203a 45/76: Revert "Dpn't assume symbol-name of keywords starts with colon", Gerd Moellmann, 2022/10/21
- pkg 0a345a1181 53/76: Make internals of Lisp_Package visible to Lisp, Gerd Moellmann, 2022/10/21
- pkg 13010d7bd0 47/76: Partially revert "Remove obarrays", Gerd Moellmann, 2022/10/21
- pkg 132f070747 58/76: New predefined hash table test for string-equal, Gerd Moellmann, 2022/10/21
- pkg 4f7c171fb4 49/76: Support specifying package size,
Gerd Moellmann <=
- pkg 9e3cfff902 51/76: Increase default symbol-table sizes, Gerd Moellmann, 2022/10/21
- pkg c98a69d650 50/76: DEFVAR some variables, Gerd Moellmann, 2022/10/21
- pkg 2030adac1c 38/76: Fake obarrays, Gerd Moellmann, 2022/10/21
- pkg 6b0304f2dd 67/76: Print package prefixes right, Gerd Moellmann, 2022/10/21
- pkg b6489ecb72 46/76: More scribbling, Gerd Moellmann, 2022/10/21
- pkg 6a8c172927 44/76: Add cö-symbol-name, Gerd Moellmann, 2022/10/21
- pkg e9b97a1f7d 48/76: Revert some unimportant changes, Gerd Moellmann, 2022/10/21
- pkg c4922c4f08 55/76: Make faces work with keywords not having : in symbol names, Gerd Moellmann, 2022/10/21
- pkg 8a59cc12da 54/76: Add amcros for keyword symbols, Gerd Moellmann, 2022/10/21
- pkg d7c793cbbf 17/76: Don't register packages in make-package, Gerd Moellmann, 2022/10/21