itli Live template help

The default itli attempts to get size() for each iteration. Unless the list size will change inside loop, we really don't need this and as all know this will cause unnecesary method call.

I changed the macro like the following.


But I got a problem (not really a problem). While expanding, IDEA stopping at $LIST$_Size to change/select list variable. But, instead I would like to stop at $LIST$.size() and copy it over $LIST_Size. I tried with $LIST_COPY$_Size, but its not working. Any ideas?

Thanks in advance.

3 comments
Comment actions Permalink

for (int $INDEX$ = 0, $LIST$_Size = $LIST$.size(); $INDEX$ < $LIST$_Size;

$INDEX$++) {

There's no need for a template variable for list size:

for (int $INDEX$ = 0, list_Size = $LIST$.size(); $INDEX$ < list_Size;
$INDEX$++) {



0
Comment actions Permalink

Try LIST_COPY with expression value LIST and "skip if defined" checked. Also
be sure to place LIST_COPY after LIST in the variables list. This works OK
for me.


"Anki" <no_mail@jetbrains.com> wrote in message
news:26709654.1060230672124.JavaMail.itn@is.intellij.net...

The default itli attempts to get size() for each iteration. Unless the

list size will change inside loop, we really don't need this and as all know
this will cause unnecesary method call.
>

I changed the macro like the following.

>

 for (int $INDEX$ = 0, $LIST$_Size = $LIST$.size(); $INDEX$ < $LIST$_Size;
$INDEX$++) {
>   $ELEMENT_TYPE$ $VAR$ = ($ELEMENT_TYPE$)$LIST$.get($INDEX$);
>   $END$
> }
> ]]>

>

But I got a problem (not really a problem). While expanding, IDEA stopping

at $LIST$_Size to change/select list variable. But, instead I would like to
stop at $LIST$.size() and copy it over $LIST_Size. I tried with
$LIST_COPY$_Size, but its not working. Any ideas?
>

Thanks in advance.



0
Comment actions Permalink

Though I really don't think there is any overhead in calling size() at each
iteration. At least I hope HotSpot is smart enough to inline the call

"Evgueny Vigdorchik" <ven@intellij.com> wrote in message
news:bgtq1k$i3j$1@is.intellij.net...

Try LIST_COPY with expression value LIST and "skip if defined" checked.

Also

be sure to place LIST_COPY after LIST in the variables list. This works OK
for me.

>
>

"Anki" <no_mail@jetbrains.com> wrote in message
news:26709654.1060230672124.JavaMail.itn@is.intellij.net...

The default itli attempts to get size() for each iteration. Unless the

list size will change inside loop, we really don't need this and as all

know

this will cause unnecesary method call.
>

I changed the macro like the following.

>

 > for (int $INDEX$ = 0, $LIST$_Size = $LIST$.size(); $INDEX$ <
$LIST$_Size;
> $INDEX$++) {
> >   $ELEMENT_TYPE$ $VAR$ = ($ELEMENT_TYPE$)$LIST$.get($INDEX$);
> >   $END$
> > }
> > ]]>

>

But I got a problem (not really a problem). While expanding, IDEA

stopping

at $LIST$_Size to change/select list variable. But, instead I would like

to

stop at $LIST$.size() and copy it over $LIST_Size. I tried with
$LIST_COPY$_Size, but its not working. Any ideas?
>

Thanks in advance.

>
>


0

Please sign in to leave a comment.