Skip to content
Browse files

Simplify escapeText.

  • Loading branch information...
1 parent 48dfbe4 commit 597b8a6f7e5bdf41efb1b92e6a3b0fab3fb8108e @adimit adimit committed
Showing with 2 additions and 3 deletions.
  1. +2 −3 Text/Search/Sphinx.hs
View
5 Text/Search/Sphinx.hs
@@ -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'.

0 comments on commit 597b8a6

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