Optimize GC while preparing judge events.
This commit is contained in:
@@ -52,6 +52,8 @@ namespace Cryville.Crtr {
|
||||
_numsrc2 = new PropSrc.Float(() => _numbuf2);
|
||||
_numsrc3 = new PropSrc.Float(() => _numbuf3);
|
||||
_numsrc4 = new PropSrc.Float(() => _numbuf4);
|
||||
_identop = new PropOp.Identifier(v => _identbuf = new Identifier(v));
|
||||
_clipop = new PropOp.Clip(v => _clipbuf = v);
|
||||
_rs.judges.Judges.TryGetValue(new Identifier(_var_pause), out _judgePause);
|
||||
foreach (var i in rs.inputs) {
|
||||
var id = i.Key;
|
||||
@@ -69,28 +71,30 @@ namespace Cryville.Crtr {
|
||||
InitJudges();
|
||||
InitScores();
|
||||
}
|
||||
Identifier _identbuf; readonly PropOp _identop;
|
||||
Clip _clipbuf; readonly PropOp _clipop;
|
||||
public void Prepare(StampedEvent sev, NoteHandler handler) {
|
||||
var tev = (Chart.Judge)sev.Unstamped;
|
||||
if (tev.Id.Key == _var_pause) throw new InvalidOperationException("Cannot assign the special judge \"pause\" to notes");
|
||||
Identifier input = default(Identifier);
|
||||
Clip clip = default(Clip);
|
||||
var def = _rs.judges.Judges[tev.Id];
|
||||
_etor.Evaluate(new PropOp.Identifier(v => input = new Identifier(v)), def.input);
|
||||
_etor.Evaluate(new PropOp.Clip(v => clip = v), def.clip);
|
||||
double st = sev.Time, et = st + sev.Duration;
|
||||
var list = evs[input];
|
||||
var ev = new JudgeEvent {
|
||||
StartTime = st,
|
||||
EndTime = et,
|
||||
StartClip = st + clip.Behind,
|
||||
EndClip = et + clip.Ahead,
|
||||
BaseEvent = tev,
|
||||
InsertEvent(tev, new Clip((float)sev.Time, (float)(sev.Time + sev.Duration)), tev.Id, handler);
|
||||
}
|
||||
void InsertEvent(Chart.Judge ev, Clip clip, Identifier id, NoteHandler handler) {
|
||||
if (id.Key == _var_pause) throw new InvalidOperationException("Cannot assign the special judge \"pause\" to notes");
|
||||
var def = _rs.judges.Judges[id];
|
||||
_etor.Evaluate(_identop, def.input);
|
||||
_etor.Evaluate(_clipop, def.clip);
|
||||
var list = evs[_identbuf];
|
||||
var jev = new JudgeEvent {
|
||||
StartTime = clip.Behind,
|
||||
EndTime = clip.Ahead,
|
||||
StartClip = clip.Behind + _clipbuf.Behind,
|
||||
EndClip = clip.Ahead + _clipbuf.Ahead,
|
||||
BaseEvent = ev,
|
||||
Definition = def,
|
||||
Handler = handler,
|
||||
};
|
||||
var index = list.BinarySearch(ev, _stcmp);
|
||||
var index = list.BinarySearch(jev, _stcmp);
|
||||
if (index < 0) index = ~index;
|
||||
list.Insert(index, ev);
|
||||
list.Insert(index, jev);
|
||||
}
|
||||
#endregion
|
||||
#region Judge
|
||||
|
Reference in New Issue
Block a user