BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
249a9476
Commit
249a9476
authored
Oct 20, 2015
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'reference-filter-replace-text-nodes-performance' into 'master'
Speed up searching for text references a bit See merge request !1648
parents
f16bfa40
e1c3077e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
4 deletions
+46
-4
CHANGELOG
CHANGELOG
+1
-0
reference_filter.rb
lib/gitlab/markdown/reference_filter.rb
+4
-4
reference_filter_spec.rb
spec/benchmarks/lib/gitlab/markdown/reference_filter_spec.rb
+41
-0
No files found.
CHANGELOG
View file @
249a9476
Please view this file on the master branch, on stable branches it's out of date.
v 8.2.0 (unreleased)
- Improved performance of replacing references in comments
- Fix duplicate repositories in GitHub import page (Stan Hu)
- Redirect to a default path if HTTP_REFERER is not set (Stan Hu)
- Show last project commit to default branch on project home page
...
...
lib/gitlab/markdown/reference_filter.rb
View file @
249a9476
...
...
@@ -15,7 +15,7 @@ module Gitlab
LazyReference
=
Struct
.
new
(
:klass
,
:ids
)
do
def
self
.
load
(
refs
)
lazy_references
,
values
=
refs
.
partition
{
|
ref
|
ref
.
is_a?
(
self
)
}
lazy_values
=
lazy_references
.
group_by
(
&
:klass
).
flat_map
do
|
klass
,
refs
|
ids
=
refs
.
flat_map
(
&
:ids
)
klass
.
where
(
id:
ids
)
...
...
@@ -107,10 +107,10 @@ module Gitlab
return
doc
if
project
.
nil?
search_text_nodes
(
doc
).
each
do
|
node
|
content
=
node
.
to_html
next
unless
content
.
match
(
pattern
)
next
if
ignored_ancestry?
(
node
)
next
unless
node
.
text
=~
pattern
content
=
node
.
to_html
html
=
yield
content
...
...
spec/benchmarks/lib/gitlab/markdown/reference_filter_spec.rb
0 → 100644
View file @
249a9476
require
'spec_helper'
describe
Gitlab
::
Markdown
::
ReferenceFilter
,
benchmark:
true
do
let
(
:input
)
do
html
=
<<-
EOF
<p>Hello @alice and @bob, how are you doing today?</p>
<p>This is simple @dummy text to see how the @ReferenceFilter class performs
when @processing HTML.</p>
EOF
Nokogiri
::
HTML
.
fragment
(
html
)
end
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:filter
)
{
described_class
.
new
(
input
,
project:
project
)
}
describe
'#replace_text_nodes_matching'
do
let
(
:iterations
)
{
6000
}
describe
'with identical input and output HTML'
do
benchmark_subject
do
filter
.
replace_text_nodes_matching
(
User
.
reference_pattern
)
do
|
content
|
content
end
end
it
{
is_expected
.
to
iterate_per_second
(
iterations
)
}
end
describe
'with different input and output HTML'
do
benchmark_subject
do
filter
.
replace_text_nodes_matching
(
User
.
reference_pattern
)
do
|
content
|
'@eve'
end
end
it
{
is_expected
.
to
iterate_per_second
(
iterations
)
}
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment