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

Improve Performance, Readability, Scalability of get_real_size()

    XMLWordPrintable

Details

    • Improvement
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.3.6, 2.3.7, 2.4.3, 2.4.4, 2.5
    • 3.1
    • Performance

    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

      Attachments

        Activity

          People

            jrchamp Jonathan Champ
            jrchamp Jonathan Champ
            Simey Lameze Simey Lameze
            Dan Poltawski Dan Poltawski
            cameron1729 cameron1729
            Matteo Scaramuccia, Andrew Lyons, Huong Nguyen, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              23/May/16