Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-39524

Improve Performance, Readability, Scalability of get_real_size()

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.3.6, 2.3.7, 2.4.3, 2.4.4, 2.5
    • Fix Version/s: 3.1
    • Component/s: Performance
    • Labels:

      Description

      The function get_real_size() is somewhat inefficient and illegible. Also, adding new matching cases degrades performance and can lead to inconsistencies in the case sensitivity of the results from values being processed (e.g. 'g').

      My proposed changes:

      • use preg_match and pow instead of a combination of strlen, substr, and verbose, repeated values
      • possible use of a static to cache pow() if you think it will be called often

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Fix Release Date:
                  23/May/16