[phobos] naming candidates for "shrinkToFit"

Steve Schveighoffer schveiguy at yahoo.com
Tue Mar 9 13:29:33 PST 2010


Some very good names came out of the newsgroup since the last release of DMD for the "shrinkToFit" function that I added recently.

The function makes the size of an allocated array match the given array slice so you can re-use the extra space via appending.

It is the equivalent of reducing the length in the old system.

The usage was:

arr.shrinkToFit();

several posters on the NG (See http://www.digitalmars.com/webnews/newsgroups.php?art_group=digitalmars.D.announce&article_id=17800) suggested some good names.  A great suggestion was to follow in the footsteps of assumeUnique, since an assumption is what we are making.

The tricky part is to identify what we are assuming.  I think these two best capture what the function does:

assumeSafeExtend
assumeSafeAppend

Don came up with the first, I came up with the second as an improvement.  Does anyone have any opinions here or other ideas?  If not, I'll just use assumeSafeAppend.

-Steve



      


More information about the phobos mailing list