perf: skip GameDataParser if there are no subscribers#2
Conversation
|
OnGameDataBlock is always subscribed to through W3GReplay.cs contructor, so even though it's nullable it's actually never the case. Is there a particular goal in mind? |
My bad I use LINQPad and just #load ".\W3G-NET\W3GNET\Parsers\*.cs"
#load ".\W3G-NET\W3GNET\Extensions\*.cs"
#load ".\W3G-NET\W3GNET\Types\*.cs"
#load ".\W3G-NET\W3GNET\Util\*.cs"
#load ".\W3G-NET\W3GNET\W3GReplay.cs"
using W3GNET.Parsers;
using System.Linq;
async Task Main()
{
var parser = new ReplayParser();
If you're just searching through your replay directory for specific metadata, skipping the gamedata parsing significantly improves performance. Eg.: new ReplayBrowser(UserProfile, Id)
.EnumerateReplays()
.Where(r => r.MapName.Contains("<some map name>"))
.Select(r => r.FileInfo) |
Ah yeah right now it just parses everything. If the goal here is to improve performance for this type of scenario I would recommend adding parameters so you can explicitly tell the parser to skip certain parts. |
I just took another look, and since the class is part of the public API, the change still seems valid.
I understand the suggestion. However, relying on both configuration and subscriber presence seems redundant. Emitting data only when there are subscribers helps keep the API surface smaller and avoids potential mismatches between configuration and actual usage |
No description provided.