Optimize bounded atom lookups
This commit is contained in:
2
AUDIT.md
2
AUDIT.md
@@ -38,6 +38,8 @@ after each item.
|
|||||||
- [x] `desktop/automation.ex` (verified keep: current module is an external-process automation harness; replacing it with `Desktop.Window` primitives would not be a local simplification)
|
- [x] `desktop/automation.ex` (verified keep: current module is an external-process automation harness; replacing it with `Desktop.Window` primitives would not be a local simplification)
|
||||||
- [x] `desktop/shell_live/sidebar_events.ex`
|
- [x] `desktop/shell_live/sidebar_events.ex`
|
||||||
- [x] `MapUtils.attr/2` replacements
|
- [x] `MapUtils.attr/2` replacements
|
||||||
|
- [x] `ui/registry.ex` O(1) lookups (verified keep: compile-time caching would freeze localized labels)
|
||||||
|
- [x] `bounded_atoms.ex` O(1) allow-lists
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|||||||
@@ -67,6 +67,8 @@ defmodule BDS.BoundedAtoms do
|
|||||||
%{id: id} -> [id]
|
%{id: id} -> [id]
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@sidebar_view_ids Enum.map(Registry.sidebar_views(), & &1.id)
|
||||||
|
@editor_route_ids Enum.map(Registry.editor_routes(), & &1.id)
|
||||||
|
|
||||||
def atom(value, allowed, fallback \\ nil)
|
def atom(value, allowed, fallback \\ nil)
|
||||||
|
|
||||||
@@ -101,13 +103,9 @@ defmodule BDS.BoundedAtoms do
|
|||||||
Enum.find(allowed, fallback, &(Atom.to_string(&1) == value))
|
Enum.find(allowed, fallback, &(Atom.to_string(&1) == value))
|
||||||
end
|
end
|
||||||
|
|
||||||
defp sidebar_views do
|
defp sidebar_views, do: @sidebar_view_ids
|
||||||
Enum.map(Registry.sidebar_views(), & &1.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp editor_routes do
|
defp editor_routes, do: @editor_route_ids
|
||||||
Enum.map(Registry.editor_routes(), & &1.id)
|
|
||||||
end
|
|
||||||
|
|
||||||
defp normalize_menu_kind("category-archive"), do: "category_archive"
|
defp normalize_menu_kind("category-archive"), do: "category_archive"
|
||||||
defp normalize_menu_kind(value), do: value
|
defp normalize_menu_kind(value), do: value
|
||||||
|
|||||||
Reference in New Issue
Block a user