Optimization on List key comparisons and return value with HashMap Consider this code:

           public class DataSt {

            DataType time;
            DataType memory;


            public DataSt(DataType time, DataType memory)
            {
                this.time=time;
                this.memory=memory;
            }

            private static void saveIt(DataSt p, DataSt p2, String keyval, List&lt;DataSt&gt; comp) {      
                  ...
                }


            private static void saveIt( String keyval, List&lt;DataSt&gt; comp) {
                     ...
         }

            public static List&lt;DataSt&gt; compO(List&lt;DataSt&gt; curR, List&lt;DataSt&gt; prevR) {            
                Map&lt;String,DataSt&gt; cur = new HashMap&lt;&gt;();Map&lt;String,DataSt&gt; prev= new HashMap&lt;&gt;();      
                for(DataSt abc:curR)
                {
                    DataSt v = new DataSt (abc.time,abc.memory);
                    cur.put(abc.key,v);
                }

                for(DataSt abc:prevR)
                {
                    DataSt values = new DataSt (abc.time,abc.memory);
                    prev.put(abc.key,v);
                }

                List&lt;DataSt&gt; comp = new ArrayList&lt;DataSt&gt;();

                for (Entry &lt; String, DataSt &gt; abc: cur.entrySet()) {
                    if (prev.containsKey(abc.getKey())) {
                        saveIt(abc.getValue(), prev.get(abc.getKey()), abc.getKey(), comp);
                    } else {
                        saveIt(abc.getKey(), comp);
                    }
                }

                for (Entry&lt;String, DataSt&gt; abc: prev.entrySet()) {
                    if (!(cur.containsKey(abc.getKey()))) {
                        saveIt(abc.getKey(), comp);
                    }
                }   
                return comp;
            }
        }


With reference to the link "https://stackoverflow.com/questions/45230104/list-key-comparisons-and-return-value". It would be great if someone could review the code and suggest optimizations.
public static List&lt;DataSt&gt; compO(List&lt;DataSt&gt; curR, List&lt;DataSt&gt; prevR) {

    Map&lt;String,DataSt&gt; cur = new HashMap&lt;&gt;();Map&lt;String,DataSt&gt; prev= new HashMap&lt;&gt;();
   curR.parallelStream().forEach(entry -&gt; cur.put(entry.key,new DataSt (entry.time,entry.memory)));
   prevR.parallelStream().forEach(entry -&gt; prev.put(entry.key,new DataSt (entry.time,entry.memory)));

    List&lt;DataSt&gt; comp = new ArrayList&lt;DataSt&gt;();
    for (Entry &lt; String, DataSt &gt; abc: cur.entrySet()) {
        final String key = abc.getKey();
        if (prev.containsKey(key)) {
            saveIt(abc.getValue(), prev.get(key), key, comp);
        } else {
            saveIt(key, comp);
        }
    }

    for (Entry&lt;String, DataSt&gt; abc: prev.entrySet()) {
        final String key = abc.getKey();
        if (!(cur.containsKey(key))) {
            saveIt(key, comp);
        }
    }
    return comp;
}


Also you can try to use parallel stream on map, but it should not be HashMap, and I'm not sure that it will be faster.