Uploaded image for project: 'Google Code-in'
  1. Google Code-in
  2. GCI-243

Collection.isEmpty() should be used to test for emptiness in Cohort.java

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Should
    • Resolution: Fixed
    • Labels:

      Description

      Replace this line https://github.com/openmrs/openmrs-core/blob/master/api/src/main/java/org/openmrs/Cohort.java#L340

      with getMemberships().isEmpty()

       

      Background Information:

      Using Collection.size() to test for emptiness works, but using Collection.isEmpty() makes the code more readable and can be more performant. The time complexity of any isEmpty() method implementation should be O(1) whereas some implementations of size() can be O\(n).

       

        Gliffy Diagrams

          Attachments

            Activity

              People

              Assignee:
              heliostrike Sai Sandeep Mutyala
              Reporter:
              dkayiwa Daniel Kayiwa
              Designated Committer:
              Sai Sandeep Mutyala Sai Sandeep Mutyala
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 hour
                  1h