Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/next-release/feature-AWSSDKforJavav2-197b121.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"type": "feature",
"category": "AWS SDK for Java v2",
"contributor": "",
"description": "Optimize ExecutionAttributes to reduce resizes and reduce hash computation cost."
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
package software.amazon.awssdk.core.interceptor;

import java.util.Collections;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Map;
import java.util.Optional;
import software.amazon.awssdk.annotations.NotThreadSafe;
Expand All @@ -38,11 +38,11 @@ public class ExecutionAttributes implements ToCopyableBuilder<ExecutionAttribute
private final Map<ExecutionAttribute<?>, Object> attributes;

public ExecutionAttributes() {
this.attributes = new HashMap<>(32);
this.attributes = new IdentityHashMap<>(64);
}

protected ExecutionAttributes(Map<? extends ExecutionAttribute<?>, ?> attributes) {
this.attributes = new HashMap<>(attributes);
this.attributes = new IdentityHashMap<>(attributes);
}

/**
Expand Down Expand Up @@ -88,7 +88,7 @@ public <U> ExecutionAttributes putAttributeIfAbsent(ExecutionAttribute<U> attrib
* Merge attributes of a higher precedence into the current lower precedence collection.
*/
public ExecutionAttributes merge(ExecutionAttributes lowerPrecedenceExecutionAttributes) {
Map<ExecutionAttribute<?>, Object> copiedAttributes = new HashMap<>(this.attributes);
Map<ExecutionAttribute<?>, Object> copiedAttributes = new IdentityHashMap<>(this.attributes);
lowerPrecedenceExecutionAttributes.getAttributes().forEach(copiedAttributes::putIfAbsent);
return new ExecutionAttributes(copiedAttributes);
}
Expand Down Expand Up @@ -167,7 +167,7 @@ public <U> ExecutionAttributes putAttributeIfAbsent(ExecutionAttribute<U> attrib
* copy() if it's because of {@link #unmodifiableExecutionAttributes(ExecutionAttributes)}.
*/
public static final class Builder implements CopyableBuilder<ExecutionAttributes.Builder, ExecutionAttributes> {
private final Map<ExecutionAttribute<?>, Object> executionAttributes = new HashMap<>(32);
private final Map<ExecutionAttribute<?>, Object> executionAttributes = new IdentityHashMap<>(64);

private Builder() {
}
Expand Down
Loading