public string Replace(string input, MatchEvaluator evaluator, int count, int startat) { if (input == null) { throw new ArgumentNullException("input"); } if (evaluator == null) { throw new ArgumentNullException("evaluator"); } if (count < -1) { throw new ArgumentOutOfRangeException("count"); } if (startat < 0 || startat > input.Length) { throw new ArgumentOutOfRangeException("startat"); } BaseMachine m = (BaseMachine)CreateMachine(); if (RightToLeft) { return(m.RTLReplace(this, input, evaluator, count, startat)); } // NOTE: If this is a cause of a lot of allocations, we can convert it to // use a ThreadStatic allocation mitigator Adapter a = new Adapter(evaluator); return(m.LTRReplace(this, input, new BaseMachine.MatchAppendEvaluator(a.Evaluate), count, startat)); }
public string Replace(string input, MatchEvaluator evaluator, int count, int startat) { if (RightToLeft) { return(BaseMachine.RTLReplace(this, input, evaluator, count, startat)); } // NOTE: If this is a cause of a lot of allocations, we can convert it to // use a ThreadStatic allocation mitigator Adapter a = new Adapter(evaluator); return(BaseMachine.LTRReplace(this, input, new BaseMachine.MatchAppendEvaluator(a.Evaluate), count, startat)); }