unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#70784: Abolish string resizing
@ 2024-05-05 12:33 Mattias Engdegård
  2024-05-05 14:04 ` Eli Zaretskii
  2024-05-06  0:53 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
  0 siblings, 2 replies; 44+ messages in thread
From: Mattias Engdegård @ 2024-05-05 12:33 UTC (permalink / raw)
  To: 70784; +Cc: Stefan Monnier

The Elisp ability to resize strings is high-cost, low-benefit, so we should abolish it.

Strings are performance-critical, and the split allocation (fixed-size metadata + variable-size data) and its indirections are not free. This is one reason why strings are comparatively expensive in Elisp compared to other languages.

With MPS there is even no use for the special-purpose string data defragger in the current GC.

String resizing occurs in exactly one place: `aset` on strings, and then only when the mutation alters the string size, in either of two cases:

* When a unibyte string byte is set to a non-byte value (> 255), which also forces the string to become multibyte.
* When a multibyte string char is set to a char of different length.

String mutation itself is very rare these days, and resizing string mutation exceptionally so.

Best and simplest would be to just turn resizing `aset` on strings into an error now. As an alternative, we could start warning about it now and make it an error in the next release. The (trivial) patches exist.

Note that this is not a proposal for abolishing string mutation in general. For example, `clear-string` would still work on any string, as would arbitrary closed mutations on unibyte strings and on ASCII multibyte strings.






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

end of thread, other threads:[~2024-05-28  2:23 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-05 12:33 bug#70784: Abolish string resizing Mattias Engdegård
2024-05-05 14:04 ` Eli Zaretskii
2024-05-05 14:18   ` Mattias Engdegård
2024-05-05 15:23     ` Eli Zaretskii
2024-05-05 16:55       ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-05 17:10         ` Eli Zaretskii
2024-05-05 18:09           ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-05 18:14             ` Eli Zaretskii
2024-05-05 20:08               ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06  1:01                 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06  6:02                   ` Gerd Möllmann
2024-05-08 23:25                     ` Richard Stallman
2024-05-08 23:24           ` Richard Stallman
2024-05-09  1:14             ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-26  9:02       ` Stefan Kangas
2024-05-26  9:17         ` Eli Zaretskii
2024-05-26 18:03           ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-26 18:45             ` Eli Zaretskii
2024-05-27  3:42               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-28  2:23           ` Richard Stallman
2024-05-05 18:09     ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-05 20:24       ` Mattias Engdegård
2024-05-05 21:14         ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-11 15:20           ` Mattias Engdegård
2024-05-11 16:21             ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-15 17:30             ` Mattias Engdegård
2024-05-15 17:47               ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-15 19:35                 ` Mattias Engdegård
2024-05-25 11:24                 ` Mattias Engdegård
2024-05-25 11:37                   ` Eli Zaretskii
2024-05-25 13:01                     ` Mattias Engdegård
2024-05-06  0:53 ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06  1:56   ` Drew Adams via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06 11:35     ` Eli Zaretskii
2024-05-06 12:29       ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-07 11:13         ` Eli Zaretskii
2024-05-07 13:41           ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06  2:41   ` Stefan Monnier via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06  4:41     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-06 10:57     ` Eli Zaretskii
2024-05-06 11:26   ` Eli Zaretskii
2024-05-06 12:23     ` Po Lu via Bug reports for GNU Emacs, the Swiss army knife of text editors
2024-05-07 11:19       ` Eli Zaretskii
2024-05-08 23:25   ` Richard Stallman

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).