Skip to content

Commit 201a1ca

Browse files
committed
intern strings
1 parent ae23165 commit 201a1ca

File tree

2 files changed

+29
-29
lines changed

2 files changed

+29
-29
lines changed

maven-resolver-api/src/main/java/org/eclipse/aether/artifact/DefaultArtifact.java

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ public DefaultArtifact(String coords, Map<String, String> properties, ArtifactTy
112112
throw new IllegalArgumentException("Bad artifact coordinates " + coords
113113
+ ", expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version>");
114114
}
115-
groupId = m.group(1);
116-
artifactId = m.group(2);
117-
extension = get(m.group(4), type == null ? "jar" : type.getExtension());
118-
classifier = get(m.group(6), type == null ? "" : type.getClassifier());
119-
this.version = emptify(m.group(7));
115+
groupId = m.group(1).intern();
116+
artifactId = m.group(2).intern();
117+
extension = get(m.group(4), type == null ? "jar" : type.getExtension()).intern();
118+
classifier = get(m.group(6), type == null ? "" : type.getClassifier()).intern();
119+
this.version = emptify(m.group(7)).intern();
120120
this.path = null;
121121
this.properties = mergeArtifactProperties(properties, (type != null) ? type.getProperties() : null);
122122
}
@@ -193,19 +193,19 @@ public DefaultArtifact(
193193
String version,
194194
Map<String, String> properties,
195195
ArtifactType type) {
196-
this.groupId = emptify(groupId);
197-
this.artifactId = emptify(artifactId);
196+
this.groupId = emptify(groupId).intern();
197+
this.artifactId = emptify(artifactId).intern();
198198
if (classifier != null || type == null) {
199-
this.classifier = emptify(classifier);
199+
this.classifier = emptify(classifier).intern();
200200
} else {
201-
this.classifier = emptify(type.getClassifier());
201+
this.classifier = emptify(type.getClassifier()).intern();
202202
}
203203
if (extension != null || type == null) {
204-
this.extension = emptify(extension);
204+
this.extension = emptify(extension).intern();
205205
} else {
206-
this.extension = emptify(type.getExtension());
206+
this.extension = emptify(type.getExtension()).intern();
207207
}
208-
this.version = emptify(version);
208+
this.version = emptify(version).intern();
209209
this.path = null;
210210
this.properties = mergeArtifactProperties(properties, (type != null) ? type.getProperties() : null);
211211
}
@@ -255,11 +255,11 @@ public DefaultArtifact(
255255
String version,
256256
Map<String, String> properties,
257257
File file) {
258-
this.groupId = emptify(groupId);
259-
this.artifactId = emptify(artifactId);
260-
this.classifier = emptify(classifier);
261-
this.extension = emptify(extension);
262-
this.version = emptify(version);
258+
this.groupId = emptify(groupId).intern();
259+
this.artifactId = emptify(artifactId).intern();
260+
this.classifier = emptify(classifier).intern();
261+
this.extension = emptify(extension).intern();
262+
this.version = emptify(version).intern();
263263
this.path = file != null ? file.toPath() : null;
264264
this.properties = copyProperties(properties);
265265
}
@@ -284,11 +284,11 @@ public DefaultArtifact(
284284
String version,
285285
Map<String, String> properties,
286286
Path path) {
287-
this.groupId = emptify(groupId);
288-
this.artifactId = emptify(artifactId);
289-
this.classifier = emptify(classifier);
290-
this.extension = emptify(extension);
291-
this.version = emptify(version);
287+
this.groupId = emptify(groupId).intern();
288+
this.artifactId = emptify(artifactId).intern();
289+
this.classifier = emptify(classifier).intern();
290+
this.extension = emptify(extension).intern();
291+
this.version = emptify(version).intern();
292292
this.path = path;
293293
this.properties = copyProperties(properties);
294294
}
@@ -302,11 +302,11 @@ public DefaultArtifact(
302302
Path path,
303303
Map<String, String> properties) {
304304
// NOTE: This constructor assumes immutability of the provided properties, for internal use only
305-
this.groupId = emptify(groupId);
306-
this.artifactId = emptify(artifactId);
307-
this.classifier = emptify(classifier);
308-
this.extension = emptify(extension);
309-
this.version = emptify(version);
305+
this.groupId = emptify(groupId).intern();
306+
this.artifactId = emptify(artifactId).intern();
307+
this.classifier = emptify(classifier).intern();
308+
this.extension = emptify(extension).intern();
309+
this.version = emptify(version).intern();
310310
this.path = path;
311311
this.properties = properties;
312312
}

maven-resolver-util/src/main/java/org/eclipse/aether/util/artifact/SubArtifact.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ public SubArtifact(
137137
public SubArtifact(
138138
Artifact mainArtifact, String classifier, String extension, Map<String, String> properties, Path path) {
139139
this.mainArtifact = requireNonNull(mainArtifact, "main artifact cannot be null");
140-
this.classifier = classifier;
141-
this.extension = extension;
140+
this.classifier = classifier == null ? null : classifier.intern();
141+
this.extension = extension == null ? null : extension.intern();
142142
this.path = path;
143143
this.properties = copyProperties(properties);
144144
}

0 commit comments

Comments
 (0)