Skip to content

Update type constraints and other optimizations #1111

@Sergio0694

Description

@Sergio0694

This follows from a conversation with @JimBobSquarePants on gitter.

Overview

There are parts of the ImageSharp codebase that were written before C# 7.3 came out, so in particular there are two missing features: the unmanaged type constraint, and the readonly modifier for struct types, or struct members.

We should consider doing a polishing pass around the codebase, including:

  • Upgrading all the various struct constraints to unmanaged (eg. in where TPixel : unmanaged, IPixel<TPixel>, instead of the previous where TPixel : struct, IPixel<TPixel>)
  • Marking all the struct-s, or at least all the various method/property getters/etc. as readonly as possible (this is more expressive and avoids safety copies by the compiler)

In particular, some of these changes were in the (now reverted) commits in #1107: 4b7718e.

Roadmap

The plan now is to wait for #1107 and #1109 to be merged, and then proceed with these changes. Side note: another unrelated follow up to do when those PRs get merged is to reintroduce the changes from 1835475 and customize processors to let them pick the right value delegate depending on their needs.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions