Skip to content

Commit

Permalink
Simplify escapeText.
Browse files Browse the repository at this point in the history
  • Loading branch information
adimit committed Aug 28, 2012
1 parent 48dfbe4 commit 597b8a6
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions Text/Search/Sphinx.hs
Expand Up @@ -63,9 +63,8 @@ escapedChars = '"':'\\':"-!@~/()*[]="
-- Most of these characters only need to be escaped in certain contexts
-- however, in normal searching they will all be ignored
escapeText :: Text -> Text
escapeText = X.concatMap (\x -> if x `elem` escapedChars
then X.pack $ '\\':[x]
else X.singleton x)
escapeText = X.intercalate "\\" . breakBy (`elem` escapedChars)
where breakBy = X.groupBy . const . fmap not

-- | The 'query' function runs a single query against the Sphinx daemon.
-- To pipeline multiple queries in a batch, use and 'runQueries'.
Expand Down

0 comments on commit 597b8a6

Please sign in to comment.