comp.lang.ada
 help / color / mirror / Atom feed
* String Buffer
@ 2021-12-02 18:17 Kevin Chadwick
  2021-12-02 19:56 ` Jeffrey R.Carter
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Kevin Chadwick @ 2021-12-02 18:17 UTC (permalink / raw)


In this thread bounded and unbounded get quite a bashing.

"https://groups.google.com/g/comp.lang.ada/c/NINmFln-YS4/m/5De5DeUAAAAJ"

I thought bounded looked useful but then I realised that it allocates the max immediately anyway. It may be useful in constrained environments but then I do not use Strings in constrained environments.

Unbounded is said to be inefficient because it re-allocates.

In Go they have strings.Builder. I assume that is what Text_Buffer is aimed to be. (Actually Go seems to have copied a lot from Ada such as AWS API, unless they both are similar to something else like JAVA). 

Is Text_Buffer usable today with GCC 11?

strings.Builder in Go behaves similarly to unbounded in that it doubles the allocation as required but it only returns a string when needed and does not have string operations. You can Grow the builder to avoid re-allocations.

"https://pkg.go.dev/strings#Builder"

If possible without breaking all of the string functions (length and separate capacity) and Unbounded Strings had a Grow function, then wouldn't that relieve the efficiency issue?

In any case avoiding unbounded strings is almost certainly in the realm of premature optimisation most of the alleged 10% of the time that it useful, but it would be nice to know of and use something akin to strings.Builder, preferably from the standard library, if it is available?

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

end of thread, other threads:[~2021-12-03  8:31 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-02 18:17 String Buffer Kevin Chadwick
2021-12-02 19:56 ` Jeffrey R.Carter
2021-12-02 20:15   ` Dmitry A. Kazakov
2021-12-02 21:06     ` Jeffrey R.Carter
2021-12-02 21:45       ` Dmitry A. Kazakov
2021-12-03  0:49         ` Kevin Chadwick
2021-12-03  5:25       ` Randy Brukardt
2021-12-03  8:31   ` ldries46
2021-12-02 20:51 ` Simon Wright
2021-12-03  8:11 ` Vadim Godunko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox