avoid reffing g:line_to in loop
it makes a difference on the flame graph but not a noticeable one in top
This commit is contained in:
parent
deedd02efd
commit
1486e5a9e0
@ -150,38 +150,38 @@ label.readout {
|
||||
|
||||
(local cq (cqueues.new))
|
||||
|
||||
(fn road-width-for [line offset]
|
||||
(+ (or offset 0)
|
||||
(case (?. line :tags :highway)
|
||||
:motorway 18
|
||||
:trunk 17
|
||||
:primary 16
|
||||
:secondary 14
|
||||
:cycleway 4
|
||||
:footway 4
|
||||
other 12)))
|
||||
|
||||
(fn cairo-road-path [g [[sx sy] & points] bounds width]
|
||||
(g:save)
|
||||
(g:set_line_width width)
|
||||
(g:move_to (* tile-size (- sx bounds.min.x))
|
||||
(* tile-size (- sy bounds.min.y)))
|
||||
(each [_ [x y] (ipairs points)]
|
||||
(let [x1 (* tile-size (- x bounds.min.x))
|
||||
y1 (* tile-size (- y bounds.min.y))]
|
||||
(g:line_to x1 y1)))
|
||||
(g:stroke)
|
||||
(g:restore))
|
||||
(fn road-width-for [line]
|
||||
(case (?. line :tags :highway)
|
||||
:motorway 18
|
||||
:trunk 17
|
||||
:primary 16
|
||||
:secondary 14
|
||||
:cycleway 4
|
||||
:footway 4
|
||||
other 12))
|
||||
|
||||
(fn cairo-road-path [g [[sx sy] & points] bounds]
|
||||
(let [min bounds.min
|
||||
{ : line_to } g]
|
||||
(g:move_to (* tile-size (- sx min.x))
|
||||
(* tile-size (- sy min.y)))
|
||||
(each [_ [x y] (ipairs points)]
|
||||
(let [x1 (* tile-size (- x min.x))
|
||||
y1 (* tile-size (- y min.y))]
|
||||
(line_to g x1 y1)))))
|
||||
|
||||
(fn cairo-roads [g lines bounds]
|
||||
(let [road-width 14]
|
||||
(g:set_source_rgb 0 0 0)
|
||||
(each [_ line (pairs lines)]
|
||||
(cairo-road-path g line.points bounds (road-width-for line)))
|
||||
(g:set_source_rgb 1 1 1)
|
||||
(each [_ line (pairs lines)]
|
||||
(cairo-road-path g line.points bounds (road-width-for line -2)))))
|
||||
(g:set_source_rgb 0 0 0)
|
||||
(each [_ line (pairs lines)]
|
||||
(g:set_line_width (road-width-for line))
|
||||
(cairo-road-path g line.points bounds )
|
||||
(g:stroke))
|
||||
(g:set_source_rgb 1 1 1)
|
||||
(each [_ line (pairs lines)]
|
||||
(g:set_line_width (- (road-width-for line) 2))
|
||||
(cairo-road-path g line.points bounds)
|
||||
(g:stroke)))
|
||||
|
||||
|
||||
(var map-surface nil)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user