/*
* Initializes all the data members that are used by Go()
*/
private void InitMatch()
{
// Use a hashtable'ed Match object if the capture numbers are sparse
if (_runmatch == null)
{
if (_runregex._caps != null)
{
_runmatch = new MatchSparse(_runregex, _runregex._caps, _runregex._capsize, _runtext, _runtextbeg, _runtextend - _runtextbeg, _runtextstart);
}
else
{
_runmatch = new Match(_runregex, _runregex._capsize, _runtext, _runtextbeg, _runtextend - _runtextbeg, _runtextstart);
}
}
else
{
_runmatch.Reset(_runregex, _runtext, _runtextbeg, _runtextend, _runtextstart);
}
// note we test runcrawl, because it is the last one to be allocated
// If there is an alloc failure in the middle of the three allocations,
// we may still return to reuse this instance, and we want to behave
// as if the allocations didn't occur. (we used to test _trackcount != 0)
if (_runcrawl != null)
{
_runtrackpos = _runtrack.Length;
_runstackpos = _runstack.Length;
_runcrawlpos = _runcrawl.Length;
return;
}
InitTrackCount();
int tracksize = _runtrackcount * 8;
int stacksize = _runtrackcount * 8;
if (tracksize < 32)
{
tracksize = 32;
}
if (stacksize < 16)
{
stacksize = 16;
}
_runtrack = new int[tracksize];
_runtrackpos = tracksize;
_runstack = new int[stacksize];
_runstackpos = stacksize;
_runcrawl = new int[32];
_runcrawlpos = 32;
}