Uploaded image for project: 'PUBLIC - Liferay Portal Community Edition'
  1. PUBLIC - Liferay Portal Community Edition
  2. LPS-76840

Use the entrySet() iterator when retrieving values from a Map

    Details

      Description

      Use the entrySet() iterator when retrieving values from a Map, instead of retrieving values from the Map while iterating over the Map keys using keySet(). Performance of this is better than calling Map.get(key) for each entry while iterating also.

      Example:

      bad performance:

      for (String name : map.keySet()) {
       String value = map.getValue(name);
      ...
      }
      

       

      good performance:

       

      for (Map.Entry<String, String> entry : map.entrySet()) {
       String value = entry.getValue();
      ...
      }
      

       

       

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Packages

                Version Package
                7.0.0 DXP FP35
                7.0.0 DXP SP7
                7.0.5 CE GA6
                7.0.X
                7.1.X
                Master