[etoys-dev] Redundant strings in image

Bert Freudenberg bert at freudenbergs.de
Sun May 2 12:45:38 EDT 2010


It's astonishing to me how many copies we have of some strings in the new dev image. They add up to more than 3 MB wasted space! See for yourself:

=====================
| f strings sorted count wasted |
strings := Bag new.
String allSubInstances
	do: [:s | strings add: s]
	displayingProgress: 'counting ...'.
sorted := SortedCollection sortBlock: [:a :b | a first >= b first].
wasted := 0.
strings asSet asArray
	do: [:s |
		count := strings occurrencesOf: s.
		count > 1 ifTrue: [
			wasted := wasted + (count - 1 * s byteSize).
			sorted add: {count*s byteSize. count. s}]]
	 displayingProgress: 'sorting ...'.
f := FileStream newFileNamed: 'bla.txt'.
[sorted do: [:each |
		f nextPutAll: '==============='; cr.
		each do: [:elem | f nextPutAll: elem asString]
			separatedBy: [f space].
		f cr]
	displayingProgress: 'writing ...'.
] ensure: [f close].
wasted asStringWithCommas
=====================

In comparison, the Etoys 4.0 release image had "only" 600 KB wasted by this.

Any idea where those strings could come from?

- Bert -




More information about the etoys-dev mailing list