symfony/symfony — pull request #7413 by jfsimon (2013-03-18 16:19:08+00:00)
Title: Changed bytes conversion method

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes

**The old way:**

```php
switch (strtolower(substr($memory, -1))) {
case 'g':
$memory *= 1024;
case 'm':
$memory *= 1024;
case 'k':
$memory *= 1024;
}
```

**The new way:**

```php
if (preg_match('#^(\d+)([bkmgt])#i', $memory, $match)) {
$shift = array('b' => 0, 'k' => 10, 'm' => 20, 'g' => 30, 't' => 40);
$memory = ($match[1] * (1 << $shift[strtolower($match[2])]));
}
```