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

    • Bug
    • Status: Closed
    • Should
    • Resolution: Fixed

    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

              heliostrike Sai Sandeep Mutyala
              dkayiwa Daniel Kayiwa
              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