@@ -13,7 +13,7 @@ use std::hash::{Hash, Hasher};
1313use std:: collections:: hash_map:: DefaultHasher ;
1414
1515/// 🔄 v0.7.7: 循环优化策略枚举
16- #[ derive( Debug , Clone , PartialEq ) ]
16+ #[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
1717pub enum LoopOptimizationStrategy {
1818 /// 循环展开 - 减少循环开销
1919 LoopUnrolling { factor : usize } ,
@@ -512,12 +512,7 @@ pub struct CompiledArrayOperation {
512512}
513513
514514/// 循环类型
515- #[ derive( Debug , Clone , PartialEq ) ]
516- pub enum LoopType {
517- While ,
518- For ,
519- ForEach ,
520- }
515+
521516
522517/// 循环优化策略
523518#[ derive( Debug , Clone , PartialEq ) ]
@@ -4138,7 +4133,7 @@ impl JitCompiler {
41384133 }
41394134
41404135 /// 🔄 v0.7.7: 计算循环模式哈希
4141- pub fn calculate_loop_pattern_hash ( & self , loop_body : & [ Statement ] , loop_type : LoopType ) -> LoopPatternKey {
4136+ pub fn calculate_loop_pattern_hash ( & mut self , loop_body : & [ Statement ] , loop_type : LoopType ) -> LoopPatternKey {
41424137 let mut hasher = DefaultHasher :: new ( ) ;
41434138
41444139 // 计算循环体的哈希
@@ -4312,12 +4307,12 @@ impl JitCompiler {
43124307
43134308 // 如果仍然超过限制,移除最少使用的条目
43144309 if self . jit_cache . len ( ) >= self . cache_config . max_cache_entries {
4315- let mut entries: Vec < _ > = self . jit_cache . iter ( ) . collect ( ) ;
4316- entries. sort_by_key ( |( _, cached ) | cached . usage_count ) ;
4310+ let mut entries: Vec < _ > = self . jit_cache . iter ( ) . map ( | ( k , v ) | ( k . clone ( ) , v . usage_count ) ) . collect ( ) ;
4311+ entries. sort_by_key ( |( _, usage_count ) | * usage_count) ;
43174312
43184313 let remove_count = self . jit_cache . len ( ) - self . cache_config . max_cache_entries + 1 ;
43194314 for ( key, _) in entries. iter ( ) . take ( remove_count) {
4320- self . jit_cache . remove ( * key) ;
4315+ self . jit_cache . remove ( key) ;
43214316 }
43224317 }
43234318
0 commit comments