Skip to content

Conversation

@GrantComm
Copy link
Owner

No description provided.

@GrantComm GrantComm requested a review from jalexanderqed June 19, 2020 13:42
Comment on lines +36 to +38
if (request.getOptionalAttendees().isEmpty()) {
attendees.removeAll(request.getOptionalAttendees());
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unnecessary. You would be removing nothing?

Comment on lines +39 to +41
if (request.getAttendees().isEmpty()) {
attendees.removeAll(request.getAttendees());
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same here.

Comment on lines +42 to +46
if (queryHelper(eventCollection, request, attendees).isEmpty()) {
attendees.removeAll(request.getOptionalAttendees());
return queryHelper(eventCollection, request, attendees);
}
return queryHelper(eventCollection, request, attendees);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should store the result of each of these calls to queryHelper rather than re-calling it. You always end up calling it one more time than necessary, which wastes time given it is a somewhat complex function.

return queryHelper(eventCollection, request, attendees);
}

private static Collection<TimeRange> queryHelper(Collection<Event> groupOfEvents, MeetingRequest request, Collection<String> attendees) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can probably just call the first parameter "events." Using the plural name makes clear that it's some sort of collection/list, so the groupOf prefix is unnecessary.

private static boolean rangeLessThanDuration(TimeRange range, long meetingDuration) {
return (range.duration() >= meetingDuration);
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rm extra line

Copy link
Collaborator

@acmcarther acmcarther left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mostly nits.

List<String> meetingAttendees = new ArrayList<String>(request.getAttendees());
if (events.isEmpty() || meetingAttendees.isEmpty()) {
// No events
List<Event> events = new ArrayList<Event>(groupOfEvents);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you doing this? Is it because you're accepting "groupOfEvents" as a "Collection"? Consider updating the function signature to accept a better collection type.

return queryHelper(eventCollection, request, attendees);
}

private static Collection<TimeRange> queryHelper(Collection<Event> groupOfEvents, MeetingRequest request, Collection<String> attendees) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made this note below, but I'll echo it here.

Collection is a really weird argument type to accept. It makes no guarantees about the performance of operations on it, which is not generally what you want when you know you'll iterate through them.

Consider accepting List<> or ArrayList<>.

}

if (start < latestEventEnd) {
if (start <= latestEventEnd) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: This = here isn't doing anything since you're detecting == above.

public Collection<TimeRange> query(Collection<Event> eventCollection, MeetingRequest request) {

public Collection<TimeRange> query(Collection<Event> eventCollection, MeetingRequest request) {
Collection<String> attendees = new ArrayList<String>();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, heres the collection.

Yeah, I said before to use generic types, but Collection is too generic, lol. List is probably what you want.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants