Groups | Search | Server Info | Login | Register
Groups > comp.lang.awk > #9980
| From | Kaz Kylheku <643-408-1753@kylheku.com> |
|---|---|
| Newsgroups | comp.lang.awk |
| Subject | Re: substr() - copying or not copying, that is here the question. |
| Date | 2025-06-01 00:01 +0000 |
| Organization | A noiseless patient Spider |
| Message-ID | <20250531165750.71@kylheku.com> (permalink) |
| References | <101f9oo$18edp$1@dont-email.me> <683b5389$0$683$14726298@news.sunsite.dk> |
On 2025-05-31, Mack The Knife <mack@the-knife.org> wrote: > In article <101f9oo$18edp$1@dont-email.me>, > Janis Papanagnou <janis_papanagnou+ng@hotmail.com> wrote: >>In the context p=index(substr(t,s),r) >>it would not be necessary to copy the substr(t,s), >>the index() function could operate on the original >>using some access "descriptor" (say, a pointer and >>a length) in read-only mode. >> >>Will (GNU) Awk do a copy of the data value or does >>it use a read-only descriptor access to the already >>existing substring of variable "t"? >> >>Currently I'm playing with some huge data and copies >>of MB sized data is costly (if it's repeatedly done >>with various substr() subscripts). > > substr() makes a copy. This is clear in the code. > > It's almost impossible to do this via read-only descriptor. It's entirely possible, with just reference counted memory management. Under the hood, you have two kinds of string types: primary strings, and strings which are views displaced into other strings. The displacing strings own a reference count on the target string, and indicate the offset and range. -- TXR Programming Language: http://nongnu.org/txr Cygnal: Cygwin Native Application Library: http://kylheku.com/cygnal Mastodon: @Kazinator@mstdn.ca
Back to comp.lang.awk | Previous | Next — Previous in thread | Find similar
substr() - copying or not copying, that is here the question. Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-05-31 18:12 +0200
Re: substr() - copying or not copying, that is here the question. mack@the-knife.org (Mack The Knife) - 2025-05-31 19:07 +0000
Re: substr() - copying or not copying, that is here the question. Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-06-01 00:16 +0200
Re: substr() - copying or not copying, that is here the question. Ben Bacarisse <ben@bsb.me.uk> - 2025-06-01 11:42 +0100
Re: substr() - copying or not copying, that is here the question. Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-06-01 13:43 +0200
Re: substr() - copying or not copying, that is here the question. gazelle@shell.xmission.com (Kenny McCormack) - 2025-06-01 12:06 +0000
Re: substr() - copying or not copying, that is here the question. Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-06-01 15:27 +0200
Re: substr() - copying or not copying, that is here the question. gazelle@shell.xmission.com (Kenny McCormack) - 2025-06-01 11:53 +0000
Re: substr() - copying or not copying, that is here the question. Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-06-01 15:47 +0200
Re: substr() - copying or not copying, that is here the question. gazelle@shell.xmission.com (Kenny McCormack) - 2025-06-01 14:17 +0000
Re: substr() - copying or not copying, that is here the question. Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-06-08 00:01 +0200
Re: substr() - copying or not copying, that is here the question. mack@the-knife.org (Mack The Knife) - 2025-06-03 06:56 +0000
Re: substr() - copying or not copying, that is here the question. gazelle@shell.xmission.com (Kenny McCormack) - 2025-06-03 11:04 +0000
Re: substr() - copying or not copying, that is here the question. Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-06-08 00:05 +0200
Re: substr() - copying or not copying, that is here the question. mack@the-knife.org (Mack The Knife) - 2025-06-08 12:35 +0000
Re: substr() - copying or not copying, that is here the question. Janis Papanagnou <janis_papanagnou+ng@hotmail.com> - 2025-06-11 11:07 +0200
Meta chat (Was: substr() - copying or not copying, that is here the question.) gazelle@shell.xmission.com (Kenny McCormack) - 2025-06-11 12:11 +0000
Re: substr() - copying or not copying, that is here the question. Kaz Kylheku <643-408-1753@kylheku.com> - 2025-06-01 00:01 +0000
csiph-web