On Wednesday 02 March 2005 01:54, Benjamin Franksen wrote:
> An implementation based on non-contiguous storage, could take
> advantage of its storage model, and almost completely avoid copying
> (at the cost of slightly increasing the overall memory footprint).
> For instance, functional concatenation can be done in constant time
> (avoiding all allocation and copying). As long as strings are
> immutable and references are properly tracked, an implementation can
> easily share the storage between different strings (except the meta
> data). I would bet that such an implementation is in the end a lot
> more efficient than any implementation based on mutability, such as
> imposed by the dataAccess string interface.
Another advantage of functional/immutable strings is that support for
unicode encodings is a lot easier and less error-prone. For instance,
since a UTF-8 character may be longer than one byte, a UTF-8 encoded
string should never be written to at an arbitrary byte index. With
immutable strings it is much easier to maintain such invariants.
The burden, in this case, would be with string analyzing functions such
as a generic 'split' function that turns a string into a pair
(front,back) of strings according to some character or substring
predicate that determines the split position. Note that such a function
would need to traverse the string character by character anyway (to
find teh split position). Thus, observing UTF-8 character boundaries
would cause almost no additional overhead.
Ben
- Replies:
- RE: memory management Jeff Hill
- References:
- RE: memory management Jeff Hill
- Re: memory management Benjamin Franksen
- Navigate by Date:
- Prev:
Re: memory management Andrew Johnson
- Next:
RE: memory management Jeff Hill
- Index:
2002
2003
2004
<2005>
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
string implementations (was: memory management) Benjamin Franksen
- Next:
RE: memory management Jeff Hill
- Index:
2002
2003
2004
<2005>
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
|