AdvancedExpressionFolding icon indicating copy to clipboard operation
AdvancedExpressionFolding copied to clipboard

Folding 'List' constructor with initial capacity is misleading

Open sabi0 opened this issue 7 years ago • 2 comments

image

Maybe it should be folded to something like hCharSequence = [4]; instead?

sabi0 avatar Jan 19 '18 14:01 sabi0

hCharSequence = [4] itself is misleading. It seems like the list has a single value of 4.

I believe that people use the initialCapacity because they care about performance. Therefore, the folding should be similar but different enough to indicate a different usage

My initial idea is one of the following 3

ArrayList<String> list_4 = new ArrayList<>(4);
var list_4 = [ , , , ]    // 1.
var list_4 = [_ _ _ _]    // 2. Or this
var list_4 = [...]        // 3. Or this


ArrayList<String> list_50 = new ArrayList<>(50);
var list_50 = [ , , ... , ]   // 1.
var list_50 = [_ _ ... _]     // 2. Or this
var list_50 = [...]           // 3. Or this

As far as the fold is concerned, all a coder cares about is that it IS using the initialCapacity constructor.

Seeing the number is not that important, and that number isn't changed much after it is declared. If I need to see the number, I can hover and see if that is correct. Therefore, I believe one of the above 3 ideas is sufficient.

What do you think @sabi0 and @cheptsov ? Any other ideas?

ciscorucinski avatar Jan 27 '18 18:01 ciscorucinski

I agree, [4] is confusing too. I hesitated about suggesting it. But didn't come up with a better option. I am not very much in favor of hiding the value. Maybe something like [] x 4?

sabi0 avatar Jan 27 '18 23:01 sabi0