Exemplo n.º 1
0
        internal bool TryGetLineDeltas(MethodId methodId, out MethodLineDeltas deltas)
        {
            if (_lazyMethodLineDeltas == null)
            {
                deltas = default(MethodLineDeltas);
                return(false);
            }

            return(_lazyMethodLineDeltas.TryGetValue(methodId, out deltas));
        }
Exemplo n.º 2
0
        private void UpdateLineDeltas(MethodId methodId, MethodLineDeltas deltas)
        {
            if (_lazyMethodLineDeltas == null)
            {
                _lazyMethodLineDeltas = new Dictionary <MethodId, MethodLineDeltas>();
            }

            if (_lazyMethodLineDeltas.TryGetValue(methodId, out var existing))
            {
                _lazyMethodLineDeltas[methodId] = existing.Merge(deltas);
            }
            else
            {
                _lazyMethodLineDeltas[methodId] = deltas;
            }
        }
Exemplo n.º 3
0
        public MethodLineDeltas Merge(MethodLineDeltas other)
        {
            int maxLength = Math.Max(_deltas.Length, other._deltas.Length);
            int minLength = Math.Min(_deltas.Length, other._deltas.Length);

            var builder = ImmutableArray.CreateBuilder <int>(maxLength);

            for (int i = 0; i < minLength; i++)
            {
                builder.Add(unchecked (_deltas[i] + other._deltas[i]));
            }

            builder.AddSubRange(_deltas, minLength);
            builder.AddSubRange(other._deltas, minLength);

            return(new MethodLineDeltas(unchecked (_delta + other._delta), builder.MoveToImmutable()));
        }