aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLouise Crow <louise.crow@gmail.com>2015-04-29 20:15:16 +0100
committerLouise Crow <louise.crow@gmail.com>2015-04-29 20:16:32 +0100
commitcf2187621231d80083da7fff09279b063e74b816 (patch)
tree77949e2b48b9afdc5e95dc878cb467cba36d6831
parent29ba105a7c2cd003c2176152af8088f70f35187f (diff)
Use respond_to? rather than a begin rescue block
Exceptions are a slow way to do control flow, and this seems clearer.
-rw-r--r--lib/acts_as_xapian/acts_as_xapian.rb17
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/acts_as_xapian/acts_as_xapian.rb b/lib/acts_as_xapian/acts_as_xapian.rb
index f742bae52..e6fdd4d00 100644
--- a/lib/acts_as_xapian/acts_as_xapian.rb
+++ b/lib/acts_as_xapian/acts_as_xapian.rb
@@ -164,16 +164,13 @@ module ActsAsXapian
@@query_parser.stemming_strategy = Xapian::QueryParser::STEM_SOME
@@query_parser.database = @@db
@@query_parser.default_op = Xapian::Query::OP_AND
- begin
- @@query_parser.set_max_wildcard_expansion(1000)
- rescue NoMethodError
- # The set_max_wildcard_expansion method was introduced in Xapian 1.2.7,
- # so may legitimately not be available.
- #
- # Large installations of Alaveteli should consider
- # upgrading, because uncontrolled wildcard expansion
- # can crash the whole server: see http://trac.xapian.org/ticket/350
- end
+ # The set_max_wildcard_expansion method was introduced in Xapian 1.2.7,
+ # so may legitimately not be available.
+ #
+ # Large installations of Alaveteli should consider
+ # upgrading, because uncontrolled wildcard expansion
+ # can crash the whole server: see http://trac.xapian.org/ticket/350
+ @@query_parser.set_max_wildcard_expansion(1000) if @@query_parser.respond_to? :set_max_wildcard_expansion
@@stopper = Xapian::SimpleStopper.new
@@stopper.add("and")