mirror of
https://github.com/wahyd4/gitlabhq.git
synced 2026-08-11 05:36:07 +10:00
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.
14 lines
294 B
Ruby
14 lines
294 B
Ruby
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
|