Thread overview
[phobos] naming candidates for "shrinkToFit"
Mar 10, 2010
Sean Kelly
March 09, 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




March 09, 2010
lgtm

Andrei

Steve Schveighoffer wrote:
> 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
> 
> 
> 
> 
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos

March 10, 2010
On Mar 9, 2010, at 1:29 PM, Steve Schveighoffer wrote:

> 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.

assumeSafeExtend would be consistent with GC.extend, but either works.