internal static void AddNode(GreenNode node, int hash) { if (AllChildrenInCache(node) && !node.IsMissing) { GreenStats.ItemAdded(); Debug.Assert(node.GetCacheHash() == hash); var idx = hash & CacheMask; s_cache[idx] = new Entry(hash, node); } }
internal static GreenNode TryGetNode(SyntaxKind kind, GreenNode child1, GreenNode child2, GreenNode child3, NodeFlags flags, out int hash) { if (CanBeCached(child1, child2, child3)) { GreenStats.ItemCacheable(); int h = hash = GetCacheHash(kind, flags, child1, child2, child3); int idx = h & CacheMask; var e = s_cache[idx]; if (e.hash == h && e.node != null && e.node.IsCacheEquivalent(kind, flags, child1, child2, child3)) { GreenStats.CacheHit(); return(e.node); } } else { hash = -1; } return(null); }