Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
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
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
22fd8ac3
Commit
22fd8ac3
authored
Jul 20, 2015
by
Eric Paris
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up mungedoc TOC by pre-compiling a regex
Brings the time to run the TOC over the docs directory from .7 seconds to .1 seconds
parent
853ea5ba
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
4 deletions
+5
-4
toc.go
cmd/mungedocs/toc.go
+5
-4
No files found.
cmd/mungedocs/toc.go
View file @
22fd8ac3
...
@@ -57,12 +57,13 @@ func buildTOC(markdown []byte) ([]byte, error) {
...
@@ -57,12 +57,13 @@ func buildTOC(markdown []byte) ([]byte, error) {
buffer
.
WriteString
(
"
\n
"
)
buffer
.
WriteString
(
"
\n
"
)
scanner
:=
bufio
.
NewScanner
(
bytes
.
NewReader
(
markdown
))
scanner
:=
bufio
.
NewScanner
(
bytes
.
NewReader
(
markdown
))
inBlockQuotes
:=
false
inBlockQuotes
:=
false
blockQuoteRegex
,
err
:=
regexp
.
Compile
(
"^```"
)
if
err
!=
nil
{
return
nil
,
err
}
for
scanner
.
Scan
()
{
for
scanner
.
Scan
()
{
line
:=
scanner
.
Text
()
line
:=
scanner
.
Text
()
match
,
err
:=
regexp
.
Match
(
"^```"
,
[]
byte
(
line
))
match
:=
blockQuoteRegex
.
Match
([]
byte
(
line
))
if
err
!=
nil
{
return
nil
,
err
}
if
match
{
if
match
{
inBlockQuotes
=
!
inBlockQuotes
inBlockQuotes
=
!
inBlockQuotes
continue
continue
...
...
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