Skip to content

Instantly share code, notes, and snippets.

@christiaan
Created May 12, 2011 14:02
Show Gist options
  • Select an option

  • Save christiaan/968554 to your computer and use it in GitHub Desktop.

Select an option

Save christiaan/968554 to your computer and use it in GitHub Desktop.
Hyphenation 20x speed increase fix
Index: hyphenation.php
===================================================================
@@ -23,13 +23,9 @@
// Convert patterns
function convert_patterns($patterns) {
- $patterns = mb_split(' ', $patterns);
- $new_patterns = array();
- for($i = 0; $i < count($patterns); $i++) {
- $value = $patterns[$i];
- $new_patterns[preg_replace('/[0-9]/', '', $value)] = $value;
- }
- return $new_patterns;
+ $keys = mb_split(' ', preg_replace('/[0-9]/', '', $patterns));
+ $values = mb_split(' ', $patterns);
+ return array_combine($keys, $values);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment