Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 340440 - [inline] inline string variable should avoid string concatenation
Summary: [inline] inline string variable should avoid string concatenation
Status: RESOLVED WONTFIX
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: PC Windows 7
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-18 11:27 EDT by Nikolay Metchev CLA
Modified: 2011-03-24 07:18 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Nikolay Metchev CLA 2011-03-18 11:27:38 EDT
When you inline the variable a in the snippet below it would be very good if eclipse remove the concatenation code:
==== INPUT =====
    String a = "1";
    String n = "b" + a + "c" + a;
================

==== OUTPUT ====
    String n = "b1c1";
================
Comment 1 Markus Keller CLA 2011-03-24 07:18:13 EDT
I agree that this could be handy sometimes, but we want to keep refactorings targeted to perform a single action (avoid guessing and being too smart, since it's not always clear that the user really wants/needs the additional smartness).

A decent compiler already concatenates the resulting "b" + "1" + "c" + "1" into one string, so this is also not a performance concern.

What we could do though, is add a quick fix that concatenates sequences of string literals into one, i.e. "b" + "1" + "c" + "1" => "b1c1", see bug 77632.