RFR: 1821: The 'timeline` API in GitHub doesn't point out the sorting order

Erik Joelsson erikj at openjdk.org
Wed Feb 15 14:07:14 UTC 2023


On Wed, 15 Feb 2023 14:02:12 GMT, Erik Joelsson <erikj at openjdk.org> wrote:

>> Hi all,
>> 
>> This patch adjusts the code to avoid GitHub changing the sorting order of the `timeline` API in the future.
>> I worry that the time complexity may change from O(N) to O(N*N), but not sure.
>> 
>> Thanks for the review.
>> 
>> Best Regards,
>> -- Guoxiong
>
> forge/src/main/java/org/openjdk/skara/forge/github/GitHubPullRequest.java line 776:
> 
>> 774:                           var secondTime = ZonedDateTime.parse(second.get("created_at").asString());
>> 775:                           return firstTime.compareTo(secondTime);
>> 776:                       })
> 
> Suggestion:
> 
>                       .max(Comparator.comparing(o -> ZonedDateTime.parse(o.get("created_at").asString())))

It will parse the date up to two times for each element, but I think that's ok. There shouldn't be that many of them.

-------------

PR: https://git.openjdk.org/skara/pull/1473


More information about the skara-dev mailing list