Uploaded image for project: 'CiviCRM'
  1. CiviCRM
  2. CRM-14106

Replace CRM_Utils_Array::value() with !empty() for performance

    Details

    • Type: Improvement
    • Status: Done/Fixed
    • Priority: Minor
    • Resolution: Fixed/Completed
    • Affects Version/s: 4.4.0
    • Fix Version/s: 4.5
    • Component/s: None
    • Labels:

      Description

      When the return value is immediately cast to boolean (e.g in an if() statement) it is pointless to use CRM_Utils_Array::value(). According to my benchmarking, using empty() is 10 times faster.
      Using empty() is also more concise and readable.
      Benchmark test attached.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                colemanw Coleman Watts
                Reporter:
                colemanw Coleman Watts
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: