Re: substr() - copying or not copying, that is here the question.

Liste des GroupesRevenir à cl awk 
Sujet : Re: substr() - copying or not copying, that is here the question.
De : 643-408-1753 (at) *nospam* kylheku.com (Kaz Kylheku)
Groupes : comp.lang.awk
Date : 01. Jun 2025, 01:01:11
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <20250531165750.71@kylheku.com>
References : 1 2
User-Agent : slrn/pre1.0.4-9 (Linux)
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

Date Sujet#  Auteur
31 May 25 * substr() - copying or not copying, that is here the question.18Janis Papanagnou
31 May 25 `* Re: substr() - copying or not copying, that is here the question.17Mack The Knife
31 May 25  +* Re: substr() - copying or not copying, that is here the question.15Janis Papanagnou
1 Jun 25  i+* Re: substr() - copying or not copying, that is here the question.8Ben Bacarisse
1 Jun 25  ii+* Re: substr() - copying or not copying, that is here the question.3Janis Papanagnou
1 Jun 25  iii`* Re: substr() - copying or not copying, that is here the question.2Kenny McCormack
1 Jun 25  iii `- Re: substr() - copying or not copying, that is here the question.1Janis Papanagnou
1 Jun 25  ii`* Re: substr() - copying or not copying, that is here the question.4Kenny McCormack
1 Jun 25  ii `* Re: substr() - copying or not copying, that is here the question.3Janis Papanagnou
1 Jun 25  ii  `* Re: substr() - copying or not copying, that is here the question.2Kenny McCormack
7 Jun 25  ii   `- Re: substr() - copying or not copying, that is here the question.1Janis Papanagnou
3 Jun 25  i`* Re: substr() - copying or not copying, that is here the question.6Mack The Knife
3 Jun 25  i +- Re: substr() - copying or not copying, that is here the question.1Kenny McCormack
7 Jun 25  i `* Re: substr() - copying or not copying, that is here the question.4Janis Papanagnou
8 Jun 25  i  `* Re: substr() - copying or not copying, that is here the question.3Mack The Knife
11 Jun 25  i   `* Re: substr() - copying or not copying, that is here the question.2Janis Papanagnou
11 Jun 25  i    `- Meta chat (Was: substr() - copying or not copying, that is here the question.)1Kenny McCormack
1 Jun 25  `- Re: substr() - copying or not copying, that is here the question.1Kaz Kylheku

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal