mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-24 10:41:11 +08:00
perf: 类私有名作用域容器改哈希表,点查由线性扫描改 O(1)
This commit is contained in:
@@ -12,8 +12,8 @@ impl Emitter {
|
||||
pub(crate) fn private_name_id(&self, name: &str, ctx: &CompileCtx) -> Result<u32, String> {
|
||||
ctx.scopes
|
||||
.private_name_map
|
||||
.iter()
|
||||
.find_map(|(n, id)| (n == name).then_some(*id))
|
||||
.get(name)
|
||||
.copied()
|
||||
.ok_or_else(|| format!("private name #{name} is not defined"))
|
||||
}
|
||||
|
||||
@@ -36,8 +36,7 @@ impl Emitter {
|
||||
pub(crate) fn private_access_brand(
|
||||
&self, _obj_reg: u32, name: &str, ctx: &mut CompileCtx,
|
||||
) -> Result<(u32, u32), String> {
|
||||
let entry = ctx.scopes.private_element_kinds.iter().find(|(n, _, _, _)| n == name);
|
||||
let Some((_, kind, is_static, brand_id)) = entry else {
|
||||
let Some((kind, is_static, brand_id)) = ctx.scopes.private_element_kinds.get(name) else {
|
||||
return Ok((0, 0));
|
||||
};
|
||||
if kind.is_none() && !is_static {
|
||||
|
||||
Reference in New Issue
Block a user