Skip to content

Commit

Permalink
Switch from HashSet to List for cross-platform deterministic node ord…
Browse files Browse the repository at this point in the history
…ering and ids.
  • Loading branch information
lilith committed Jan 29, 2024
1 parent e86fba4 commit f6e7a9e
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/Imageflow/Fluent/ImageJob.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
namespace Imageflow.Fluent
{
[Obsolete("Use ImageJob instead")]
public class FluentBuildJob : ImageJob
{

}
public class FluentBuildJob : ImageJob;

public class ImageJob: IDisposable
{
Expand Down Expand Up @@ -260,18 +257,18 @@ private class MemoryStreamJsonProvider : IJsonResponseProvider
}


private object BuildJsonWithPlaceholders()
{
var inputIo = _inputs.Select(pair =>
new {io_id = pair.Key, direction = "in", io = new {placeholder = (string?) null}});
var outputIo = _outputs.Select(pair =>
new {io_id = pair.Key, direction = "out", io = new {placeholder = (string?) null}});
return new
{
io = inputIo.Concat(outputIo).ToArray(),
framewise = ToFramewise()
};
}
// private object BuildJsonWithPlaceholders()
// {
// var inputIo = _inputs.Select(pair =>
// new {io_id = pair.Key, direction = "in", io = new {placeholder = (string?) null}});
// var outputIo = _outputs.Select(pair =>
// new {io_id = pair.Key, direction = "out", io = new {placeholder = (string?) null}});
// return new
// {
// io = inputIo.Concat(outputIo).ToArray(),
// framewise = ToFramewise()
// };
// }

private static ITemporaryFileProvider SystemTempProvider()
{
Expand Down Expand Up @@ -485,18 +482,19 @@ internal async Task<IPreparedFilesystemJob> WriteJsonJobAndInputs(CancellationTo



private readonly HashSet<BuildItemBase> _nodesCreated = new HashSet<BuildItemBase>();
private readonly List<BuildItemBase> _nodesCreated = new List<BuildItemBase>(10);



internal void AddNode(BuildItemBase n)
{
AssertReady();

if (!_nodesCreated.Add(n))
if (_nodesCreated.Contains(n))
{
throw new ImageflowAssertionFailed("Cannot add duplicate node");
}
_nodesCreated.Add(n);
if (n.Canvas != null && !_nodesCreated.Contains(n.Canvas))// || n.Canvas.Builder != this))
{
throw new ImageflowAssertionFailed("You cannot use a canvas node from a different ImageJob");
Expand Down

0 comments on commit f6e7a9e

Please sign in to comment.