Sujet : Re: substr() - copying or not copying, that is here the question.
De : mack (at) *nospam* the-knife.org (Mack The Knife)
Groupes : comp.lang.awkDate : 31. May 2025, 20:07:53
Autres entêtes
Organisation : Knife Sharpeners, Inc.
Message-ID : <683b5389$0$683$14726298@news.sunsite.dk>
References : 1
User-Agent : trn 4.0-test77 (Sep 1, 2010)
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.
Consider something like
x = substr($0, 10, 15)
getline
print x
Gawk manages the storage such that for something like
your example the copy will be released after index()
returns a value.
Date | Sujet | # | | Auteur |
31 May 25 | substr() - copying or not copying, that is here the question. | 18 | | Janis Papanagnou |
31 May 25 |  Re: substr() - copying or not copying, that is here the question. | 17 | | Mack The Knife |
31 May 25 |   Re: substr() - copying or not copying, that is here the question. | 15 | | Janis Papanagnou |
1 Jun 25 |    Re: substr() - copying or not copying, that is here the question. | 8 | | Ben Bacarisse |
1 Jun 25 |     Re: substr() - copying or not copying, that is here the question. | 3 | | Janis Papanagnou |
1 Jun 25 |      Re: substr() - copying or not copying, that is here the question. | 2 | | Kenny McCormack |
1 Jun 25 |       Re: substr() - copying or not copying, that is here the question. | 1 | | Janis Papanagnou |
1 Jun 25 |     Re: substr() - copying or not copying, that is here the question. | 4 | | Kenny McCormack |
1 Jun 25 |      Re: substr() - copying or not copying, that is here the question. | 3 | | Janis Papanagnou |
1 Jun 25 |       Re: substr() - copying or not copying, that is here the question. | 2 | | Kenny McCormack |
7 Jun 25 |        Re: substr() - copying or not copying, that is here the question. | 1 | | Janis Papanagnou |
3 Jun 25 |    Re: substr() - copying or not copying, that is here the question. | 6 | | Mack The Knife |
3 Jun 25 |     Re: substr() - copying or not copying, that is here the question. | 1 | | Kenny McCormack |
7 Jun 25 |     Re: substr() - copying or not copying, that is here the question. | 4 | | Janis Papanagnou |
8 Jun 25 |      Re: substr() - copying or not copying, that is here the question. | 3 | | Mack The Knife |
11 Jun 25 |       Re: substr() - copying or not copying, that is here the question. | 2 | | Janis Papanagnou |
11 Jun 25 |        Meta chat (Was: substr() - copying or not copying, that is here the question.) | 1 | | Kenny McCormack |
1 Jun 25 |   Re: substr() - copying or not copying, that is here the question. | 1 | | Kaz Kylheku |