Le 30 mai 2014 à 09:39, Philippe Marschall a écrit :

> Hi
> 
> This is an idea I stole from somebody else. The assumption is that you have a 
> lot of Strings in the image that are equal. We could therefore remove the 
> duplicates and make all the objects refer to the same instance.


I worked on a String optimisation for a Java virtual machine dedicated to small 
hardwares.
A string was represented by an array of bytes (UTF8 or ASCII encoding), a start 
position, and the number of characters of the string.
It allows to reuse the internal byte array for different strings but the String 
object was different for each String.
With this approach, you are able to save a lot of memory (but with some CPU 
overhead) and you don't have a problems because you have different String 
objects for each String.

ex: b1: 'Hello World! It's a sunny day'

'Hello World! It's a sunny day' : start = 0, count = 29, value b1
'Hello' : start = 0, count = 5, value b1
'Hello World!' : start = 0, count = 12, value b1
'World': start = 6, count = 5, value b1


I don't see how it may be applied to Smalltalk and it makes sense.

Christophe.

Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to