Re: [squeak-smalltalk/squeak-object-memory] Avoid growth when filling large collections (Issue #160)

Luciano Notarfrancesco <[email protected]> Wed, 17 Jun 2026 16:28:34 +0700
Newsgroups gmane.comp.lang.smalltalk.squeak.general
Message-ID <CAL5GDyoyOsF=T1EB0znS-rJ2pzRPhvEe+EJdTepO3+yrUDsvXA@mail.gmail.com>
In Cuis Juan decided to remove #new: from collections that can grow (Set,
OrderedCollection, etc), and instead implement #newWithRoomForMoreThan: n.
I personally don’t like the selector (too verbose and hard to remember),
I’d use something like #allocate: perhaps, a single word.

But do we really need two different messages? What should “Set new: n”
mean? I think it should be a set that can hold up to n elements without
growing, not the size of the array used internally.

Cheers,
Luciano


On Wed, Jun 17, 2026 at 15:59 Marcel Taeumel via Squeak-dev <
[email protected]> wrote:

> *marceltaeumel* created an issue
> (squeak-smalltalk/squeak-object-memory#160)
> <https://github.com/squeak-smalltalk/squeak-object-memory/issues/160>
>
> When filling large collections, we have new: to set the expected capacity
> and new:withAll: to also define the objects to put in.
>
> However, as we do not expose a collection's growth strategy, the use of
> new: gets tricky if one wants to avoid extra growth at all cost, e.g.,
> when having millions of things.
>
> The growth strategy is hidden within a collection's implementation.
>
> A client would have to expose a best guess to avoid growth:
>
> bigDatabase := IdentityDictionary new: allObjects size * 4 // 3 + 16.
>
> Here numObjects * 4 // 3 + 16 is that guess. Maybe we want to offer a
> newForSizeNoGrow:.
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/squeak-smalltalk/squeak-object-memory/issues/160?email_source=notifications&email_token=BFYAK6PTQECKRUJ5EZ6KAPT5AJMWBA5CNFSL4Z3JMQ5C6L3HNF2C22DVMIXUS43TOVSS6NBWHAYTMOBTHE3TNJTSMVQXG33OVJZXKYTTMNZGSYTFMSSWK5TFNZ2KYZTPN52GK4S7MNWGSY3L>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/BFYAK6M5I776WDHUWYZSF4T5AJMWBAVCNFSNUABFKJSXA33TNF2G64TZHM2DKNBYHA3TANRUHNEXG43VMU5TINRYGE3DQMZZG43KC5QC>
> .
> Triage notifications, keep track of coding agent tasks and review pull
> requests on the go with GitHub Mobile for iOS
> <https://github.com/notifications/mobile/ios/BFYAK6LUHMJV5P5HQ2T6LQ35AJMWBA5CNFSL4Z3JMQ5C6L3HNF2C22DVMIXUS43TOVSS6NBWHAYTMOBTHE3TNJTSMVQXG33OVJZXKYTTMNZGSYTFMSSWK5TFNZ2KUZTPN52GK4S7NFXXG>
> and Android
> <https://github.com/notifications/mobile/android/BFYAK6LAIDA4HXH3G4ZGYQ35AJMWBA5CNFSL4Z3JMQ5C6L3HNF2C22DVMIXUS43TOVSS6NBWHAYTMOBTHE3TNJTSMVQXG33OVJZXKYTTMNZGSYTFMSSWK5TFNZ2K4ZTPN52GK4S7MFXGI4TPNFSA>.
> Download it today!
> You are receiving this because you are subscribed to this thread.Message
> ID: <squeak-smalltalk/squeak-object-memory/issues/[email protected]>
> Squeak-dev mailing list -- [email protected]
> To unsubscribe send an email to
> [email protected]

Squeak-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]