diff options
author | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-30 18:16:53 +0100 |
---|---|---|
committer | Yorick Peterse <yorickpeterse@gmail.com> | 2015-12-31 15:46:47 +0100 |
commit | 054df415f94abe1e517a729e53cdb325d592d31b (patch) | |
tree | b7e5d560e39f05fdae0e5ee0ba654739eab59094 /spec | |
parent | d3951dfaa13b9aaf11695ef10fa63456ac75cc48 (diff) | |
download | gitlab-ce-autocomplete-performance.tar.gz |
Optimize CSS expressions produced by Nokogiriautocomplete-performance
Nokogiri produces inefficient XPath expressions when given CSS
expressions such as "a.gfm". Luckily these expressions can be optimized
quite easily while still achieving the same results.
In the two cases where this optimization is applied the run time has
been reduced from around 170 ms to around 15 ms.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/banzai/querying_spec.rb | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/spec/lib/banzai/querying_spec.rb b/spec/lib/banzai/querying_spec.rb new file mode 100644 index 00000000000..27da2a7439c --- /dev/null +++ b/spec/lib/banzai/querying_spec.rb @@ -0,0 +1,13 @@ +require 'spec_helper' + +describe Banzai::Querying do + describe '.css' do + it 'optimizes queries for elements with classes' do + document = double(:document) + + expect(document).to receive(:xpath).with(/^descendant::a/) + + described_class.css(document, 'a.gfm') + end + end +end |