Skip to content
This repository has been archived by the owner on Jul 13, 2021. It is now read-only.

Commit

Permalink
Merge pull request #246 from JuliaPlots/sd/perfbug
Browse files Browse the repository at this point in the history
make clear field access faster
  • Loading branch information
SimonDanisch authored Dec 8, 2019
2 parents f2d01f3 + 2cacd32 commit 77965ae
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions src/scenes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ mutable struct Scene <: AbstractScene
events::Events

px_area::Node{IRect2D}
# plot_area::Node{IRect2D}
clear::Bool

camera::Camera
camera_controls::RefValue
Expand All @@ -36,11 +36,7 @@ end

Base.haskey(scene::Scene, key::Symbol) = haskey(scene.attributes, key)
function Base.getindex(scene::Scene, key::Symbol)
if haskey(scene.attributes, key)
return scene.attributes[key]
else
return scene.theme[key]
end
return haskey(scene.attributes, key) ? scene.attributes[key] : scene.theme[key]
end

function Base.setindex!(scene::Scene, value, key::Symbol)
Expand All @@ -50,6 +46,7 @@ end
function Scene(
events::Events,
px_area::Node{IRect2D},
clear::Bool,
camera::Camera,
camera_controls::RefValue,
scene_limits,
Expand All @@ -67,7 +64,7 @@ function Scene(
updated = Node(false)

scene = Scene(
parent, events, px_area, camera, camera_controls,
parent, events, px_area, clear, camera, camera_controls,
Node{Union{Nothing, FRect3D}}(scene_limits),
transformation, plots, theme, attributes,
children, current_screens, updated
Expand Down Expand Up @@ -106,9 +103,7 @@ function Scene(
end


function Scene(
;scene_attributes...
)
function Scene(;clear = true, scene_attributes...)
events = Events()
theme = current_default_theme(; scene_attributes...)
attributes = copy(theme)
Expand All @@ -123,6 +118,7 @@ function Scene(
scene = Scene(
events,
px_area,
clear,
Camera(px_area),
RefValue{Any}(EmptyCamera()),
nothing,
Expand All @@ -146,24 +142,25 @@ function Scene(
scene::Scene;
events = scene.events,
px_area = scene.px_area,
clear = false,
cam = scene.camera,
camera_controls = scene.camera_controls,
transformation = Transformation(scene),
theme = copy(theme(scene)),
current_screens = scene.current_screens,
clear = false,
kw_args...
)
child = Scene(
events,
px_area,
clear,
cam,
camera_controls,
nothing,
transformation,
AbstractPlot[],
merge(current_default_theme(), theme),
merge!(Attributes(clear = clear; kw_args...), scene.attributes),
merge!(Attributes(; kw_args...), scene.attributes),
Scene[],
current_screens,
scene
Expand All @@ -181,13 +178,14 @@ function Scene(parent::Scene, area; clear = false, attributes...)
child = Scene(
events,
px_area,
clear,
Camera(px_area),
RefValue{Any}(EmptyCamera()),
nothing,
Transformation(),
AbstractPlot[],
current_default_theme(clear = clear; attributes...),
merge!(Attributes(clear = clear; attributes...), parent.attributes),
current_default_theme(; attributes...),
merge!(Attributes(; attributes...), parent.attributes),
Scene[],
parent.current_screens,
parent
Expand Down

2 comments on commit 77965ae

@SimonDanisch
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator register()

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/6152

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if Julia TagBot is installed, or can be done manually through the github interface, or via:

git tag -a v0.9.11 -m "<description of version>" 77965aeb0cb528c8eefbc172c1fb1a5162b46cb8
git push origin v0.9.11

Please sign in to comment.