You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@reef.apache.org by "Dongjoon Hyun (JIRA)" <ji...@apache.org> on 2015/09/29 21:20:04 UTC
[jira] [Created] (REEF-791) Replace inefficient use of keySet
iterator with entrySet iterator
Dongjoon Hyun created REEF-791:
----------------------------------
Summary: Replace inefficient use of keySet iterator with entrySet iterator
Key: REEF-791
URL: https://issues.apache.org/jira/browse/REEF-791
Project: REEF
Issue Type: Improvement
Affects Versions: 0.12
Reporter: Dongjoon Hyun
Assignee: Dongjoon Hyun
Priority: Trivial
Fix For: 0.13
We can improve performance by replacing `keySet` with `entrySet`. For example, see the following code pattern change in REEF-Wake.
{code}
- for (final Class<? extends T> clazz : clazzToCodecMap.keySet()) {
- clazzToEncoderMap.put(clazz, clazzToCodecMap.get(clazz));
- clazzToDecoderMap.put(clazz, clazzToCodecMap.get(clazz));
+ for (final Entry<Class<? extends T>, Codec<? extends T>> e : clazzToCodecMap.entrySet()) {
+ clazzToEncoderMap.put(e.getKey(), e.getValue());
+ clazzToDecoderMap.put(e.getKey(), e.getValue());
{code}
As of today, we can find 6 candidates.
* reef-io
* CodecRamMap.java
* reef-tang
* CommandLine.java
* InjectorImpl.java
* Tint.java
* reef-util
* CacheImpl.java
* reef-wake
* MultiCodec.java
We can improve all except `InjectorImpl.java' using `TracingMonotonicTreeMap.java' that doesn't support `entrySet`.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)