Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Simplify escapeText.

  • Loading branch information...
commit 597b8a6f7e5bdf41efb1b92e6a3b0fab3fb8108e 1 parent 48dfbe4
@adimit adimit authored
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'.
Please sign in to comment.
Something went wrong with that request. Please try again.