Skip to content
Browse files

Use unset()

Use a faster, more reliable method for removing items from the word search array.
  • Loading branch information...
1 parent ebe8e60 commit 1a0dd47f488c2ddda512f0079d9fafe0e095f158 @ericmann committed
Showing with 8 additions and 8 deletions.
  1. +2 −2 classes/EnchantSpell.php
  2. +2 −2 classes/GoogleSpell.php
  3. +2 −2 classes/PSpell.php
  4. +2 −2 classes/PSpellShell.php
View
4 classes/EnchantSpell.php
@@ -19,8 +19,8 @@ class EnchantSpell extends SpellChecker {
*/
function &checkWords($lang, $words) {
foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
- if ( $index = array_search( $ignore, $words ) ) {
- array_splice( $words, $index, 1 );
+ if ( false !== $index = array_search( $ignore, $words ) ) {
+ unset( $words[ $index ] );
}
}
$r = enchant_broker_init();
View
4 classes/GoogleSpell.php
@@ -17,8 +17,8 @@ class GoogleSpell extends SpellChecker {
*/
function &checkWords($lang, $words) {
foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
- if ( $index = array_search( $ignore, $words ) ) {
- array_splice( $words, $index, 1 );
+ if ( false !== $index = array_search( $ignore, $words ) ) {
+ unset( $words[ $index ] );
}
}
$wordstr = implode(' ', $words);
View
4 classes/PSpell.php
@@ -17,8 +17,8 @@ class PSpell extends SpellChecker {
*/
function &checkWords($lang, $words) {
foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
- if ( $index = array_search( $ignore, $words ) ) {
- array_splice( $words, $index, 1 );
+ if ( false !== $index = array_search( $ignore, $words ) ) {
+ unset( $words[ $index ] );
}
}
$plink = $this->_getPLink($lang);
View
4 classes/PSpellShell.php
@@ -17,8 +17,8 @@ class PSpellShell extends SpellChecker {
*/
function &checkWords($lang, $words) {
foreach ( explode( ' ', $this->config['general.ignored_words'] ) as $ignore ) {
- if ( $index = array_search( $ignore, $words ) ) {
- array_splice( $words, $index, 1 );
+ if ( false !== $index = array_search( $ignore, $words ) ) {
+ unset( $words[ $index ] );
}
}
$cmd = $this->_getCMD($lang);

0 comments on commit 1a0dd47

Please sign in to comment.
Something went wrong with that request. Please try again.