There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull
example requires it.
Consider adopting the new property pattern, wherever you use IsNullOrEmpty
.
string? hello = "hello world";
using System; | |
namespace PixelVision.Engine.Chips.Graphics.Sprites | |
{ | |
public interface ITextureData | |
{ | |
int Width { get; } | |
int Height { get; } | |
int GetPixel(int x, int y); | |
void SetPixel(int x, int y, int value); |
using BenchmarkDotNet.Attributes; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Numerics; | |
using System.Runtime.CompilerServices; | |
using System.Text; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using BenchmarkDotNet.Configs; |
public static void Main(string[] args) | |
{ | |
var x = Flip(10000); | |
var y = FlipNew(10000); | |
////var bench = new ReverseBench(); | |
////bench.FlipInSets64Bit(); | |
//BenchmarkRunner.Run<ReverseBench>(); | |
} | |
public unsafe static ulong Flip(ulong data) |
using System; | |
using System.Collections.Generic; | |
using System.Collections; | |
using System.Diagnostics; | |
using System.Runtime.CompilerServices; | |
namespace IListPerformance | |
{ | |
public class Program | |
{ |
using System; | |
using Microsoft.AspNetCore.Builder; | |
using Microsoft.AspNetCore.Hosting; | |
using Microsoft.AspNetCore.Routing; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.AspNetCore; | |
using Microsoft.Extensions.DependencyInjection; | |
public class Startup | |
{ |
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
namespace SimRing { | |
class Program { | |
static void Main(string[] args) { | |
const int n = 1000; | |
const int m = 1000; |
const int maxBuffer = 1024; | |
while (true) | |
{ | |
var result = await application.Output.ReadAsync(); | |
var buffer = result.Buffer; | |
// Check if we have enough to perform a write | |
if (buffer.Length >= maxBuffer) | |
{ |
using BenchmarkDotNet.Attributes; | |
using BenchmarkDotNet.Running; | |
using System; | |
namespace delegate_interface | |
{ | |
public class Program : IFoo | |
{ | |
const int InnerLoopCount = 10000; |
using System; | |
using System.Text.Json; | |
using System.Threading.Tasks; | |
using Microsoft.AspNetCore.Http; | |
using Microsoft.Extensions.DependencyInjection; | |
using static Microsoft.AspNetCore.Builder.ArgumentType; | |
namespace Microsoft.AspNetCore.Builder | |
{ | |
public static class RequestDelegateExtensions |
There are lots of cases that you can improve. The examples use nullable reference types, but only the WhenNotNull
example requires it.
Consider adopting the new property pattern, wherever you use IsNullOrEmpty
.
string? hello = "hello world";