# Code Review: re

**URL:** <https://www.ruby-forum.com/t/code-review-re/161140>\
**Category:** IronRuby\
**Created:** [February 23, 2009, 7:36pm UTC](https://www.ruby-forum.com/t/code-review-re/161140 "2009-02-23T19:36:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shri\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@Shri\_B](https://www.ruby-forum.com/u/Shri_B)\
**Post date:** [February 23, 2009, 7:36pm UTC](https://www.ruby-forum.com/t/code-review-re/161140/1 "2009-02-23T19:36:32Z")

</div>

tfpt review “/shelveset:re;REDMOND\sborde”

Comment :  
Regexp literal support for /o.  
/foo/ should compare equal with /foo/o, so we ensure that  
RubyRegexpOptions.Once is passed into the RubyOps runtime helper, but we  
then remove it in the RubyRegex constructor  
Caching of the RubyRegex (and the underlying  
System.Text.RegularExpressions.Regex) for regexp literals so that the  
expression is processed only once  
Sort the method names in the generated ReflectionCache. This will make  
reduce the chances of conflicts during merging. Currently, the order is  
whatever System.Reflection choses.

---

<div class="post-metadata">

**Author:** ![Shri\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@Shri\_B](https://www.ruby-forum.com/u/Shri_B)\
**Post date:** [February 23, 2009, 8:17pm UTC](https://www.ruby-forum.com/t/code-review-re/161140/2 "2009-02-23T20:17:05Z")

</div>

ReflectionCacheGenerator: More concise way how to sort an array:

var methods = ReflectMethods(typeof(RubyOps)).Values;  
Array.Sort(methods, (m1, m2) =\> m1.Name.CompareTo(m2.Name));

ScringConstructor:

I would prefer TransformConcatenation to take 2 parameters (Expr  
regexOptions, Expr regexCache) rather than params array.

Then this would not be necessary:  
List\<MSA.Expression\> allArgs = new  
List\<MSA.Expression\>(2 + additionalArgs.Length);  
allArgs.Add(paramArray);  
allArgs.Add(codePage);  
allArgs.AddRange(additionalArgs);

and we could do just:  
if (regexOptions != null)  
opFactory(“N”).OpCall(paramArray, codePage,  
regexOptions, regexCache) : …

Other than that looks good.

Tomas

---

<div class="post-metadata">

**Author:** ![Shri\_B](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/898d66/32.png) [@Shri\_B](https://www.ruby-forum.com/u/Shri_B)\
**Post date:** [February 23, 2009, 10:03pm UTC](https://www.ruby-forum.com/t/code-review-re/161140/3 "2009-02-23T22:03:39Z")

</div>

Array.Sort(methods, …) does not work because methods is an  
IEnumerable, not IList, and so I have to create an auxiliary list. I did  
use the inline lambda for the comparision delegate. Changed  
TransformConcatenation too.

Thanks,  
Shri
