[ 
https://issues.apache.org/jira/browse/IMAGING-151?focusedWorklogId=359885&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-359885
 ]

ASF GitHub Bot logged work on IMAGING-151:
------------------------------------------

                Author: ASF GitHub Bot
            Created on: 14/Dec/19 23:25
            Start Date: 14/Dec/19 23:25
    Worklog Time Spent: 10m 
      Work Description: kinow commented on pull request #64: IMAGING-151: use a 
copy of the list, make members package-protected/private, and re-use Comparator
URL: https://github.com/apache/commons-imaging/pull/64#discussion_r357943708
 
 

 ##########
 File path: 
src/main/java/org/apache/commons/imaging/palette/LongestAxisMedianCut.java
 ##########
 @@ -59,28 +59,14 @@ public boolean performNextMedianCut(final List<ColorGroup> 
colorGroups, final bo
     private void doCut(final ColorGroup colorGroup, final ColorComponent mode,
             final List<ColorGroup> colorGroups, final boolean ignoreAlpha) 
throws ImageWriteException {
 
-        final Comparator<ColorCount> comp = (c1, c2) -> {
-            switch (mode) {
-                case ALPHA:
-                    return c1.alpha - c2.alpha;
-                case RED:
-                    return c1.red - c2.red;
-                case GREEN:
-                    return c1.green - c2.green;
-                case BLUE:
-                    return c1.blue - c2.blue;
-                default:
-                    return 0;
-            }
-        };
-
-        Collections.sort(colorGroup.colorCounts, comp);
+        final List<ColorCount> colorCounts = colorGroup.getColorCounts();
+        Collections.sort(colorCounts, new ColorCountComparator(mode));
 
 Review comment:
   Sorting the local variable now.
 
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 359885)
    Time Spent: 0.5h  (was: 20m)

> ColorGroup.color_counts is mutable public List and is multiply sorted
> ---------------------------------------------------------------------
>
>                 Key: IMAGING-151
>                 URL: https://issues.apache.org/jira/browse/IMAGING-151
>             Project: Commons Imaging
>          Issue Type: Bug
>    Affects Versions: 1.0-alpha1
>            Reporter: Sebb
>            Assignee: Bruno P. Kinoshita
>            Priority: Major
>             Fix For: 1.0-alpha2
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> ColorGroup.color_counts is a public mutable List.
> Also the List is re-sorted in several places
> It looks like the field is only used within the package, so can be package 
> protected.
> However it seems odd that the shared list is re-sorted by
> MedianCutLongestAxisImplementation.doCut
> and
> MedianCutMostPopulatedBoxesImplementation.performNextMedianCut (twice)



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to