Skip to content

Commit

Permalink
Use params span where possible.
Browse files Browse the repository at this point in the history
  • Loading branch information
alexrp committed Nov 13, 2024
1 parent 9d78c0f commit da75bf4
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions src/language/core/Diagnostics/Diagnostic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public static Diagnostic Create(
DiagnosticSeverity severity,
DiagnosticCode code,
string message,
params (SourceTextSpan Span, string Message)[] notes)
params ReadOnlySpan<(SourceTextSpan Span, string Message)> notes)
{
return Create(tree, span, severity, code, message, notes.AsEnumerable());
return Create(tree, span, severity, code, message, notes.ToArray().AsEnumerable());
}

public static Diagnostic Create(
Expand Down
4 changes: 2 additions & 2 deletions src/language/core/ModulePath.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ private ModulePath(ImmutableArray<string> components)

public static bool operator !=(ModulePath? left, ModulePath? right) => !(left == right);

public static ModulePath Create(params string[] components)
public static ModulePath Create(params ReadOnlySpan<string> components)
{
return Create(components.AsEnumerable());
return Create(components.ToArray().AsEnumerable());
}

public static ModulePath Create(IEnumerable<string> components)
Expand Down
10 changes: 5 additions & 5 deletions src/language/core/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1046,13 +1046,13 @@ override Vezel.Celerity.Language.Text.StringSourceText.Count.get -> int
override Vezel.Celerity.Language.Text.StringSourceText.GetEnumerator() -> System.CharEnumerator!
override Vezel.Celerity.Language.Text.StringSourceText.this[int index].get -> char
override Vezel.Celerity.Language.Text.StringSourceText.ToString(Vezel.Celerity.Language.Text.SourceTextSpan span) -> string!
static Vezel.Celerity.Language.Diagnostics.Diagnostic.Create(Vezel.Celerity.Language.Syntax.SyntaxTree! tree, Vezel.Celerity.Language.Text.SourceTextSpan span, Vezel.Celerity.Language.Diagnostics.DiagnosticSeverity severity, Vezel.Celerity.Language.Diagnostics.DiagnosticCode code, string! message, params (Vezel.Celerity.Language.Text.SourceTextSpan Span, string! Message)[]! notes) -> Vezel.Celerity.Language.Diagnostics.Diagnostic!
static Vezel.Celerity.Language.Diagnostics.Diagnostic.Create(Vezel.Celerity.Language.Syntax.SyntaxTree! tree, Vezel.Celerity.Language.Text.SourceTextSpan span, Vezel.Celerity.Language.Diagnostics.DiagnosticSeverity severity, Vezel.Celerity.Language.Diagnostics.DiagnosticCode code, string! message, params System.ReadOnlySpan<(Vezel.Celerity.Language.Text.SourceTextSpan Span, string! Message)> notes) -> Vezel.Celerity.Language.Diagnostics.Diagnostic!
static Vezel.Celerity.Language.Diagnostics.Diagnostic.Create(Vezel.Celerity.Language.Syntax.SyntaxTree! tree, Vezel.Celerity.Language.Text.SourceTextSpan span, Vezel.Celerity.Language.Diagnostics.DiagnosticSeverity severity, Vezel.Celerity.Language.Diagnostics.DiagnosticCode code, string! message, System.Collections.Generic.IEnumerable<(Vezel.Celerity.Language.Text.SourceTextSpan Span, string! Message)>! notes) -> Vezel.Celerity.Language.Diagnostics.Diagnostic!
static Vezel.Celerity.Language.Diagnostics.DiagnosticCode.Create(string! name) -> Vezel.Celerity.Language.Diagnostics.DiagnosticCode
static Vezel.Celerity.Language.Diagnostics.DiagnosticCode.operator !=(Vezel.Celerity.Language.Diagnostics.DiagnosticCode left, Vezel.Celerity.Language.Diagnostics.DiagnosticCode right) -> bool
static Vezel.Celerity.Language.Diagnostics.DiagnosticCode.operator ==(Vezel.Celerity.Language.Diagnostics.DiagnosticCode left, Vezel.Celerity.Language.Diagnostics.DiagnosticCode right) -> bool
static Vezel.Celerity.Language.Diagnostics.DiagnosticCode.TryCreate(string! name, out Vezel.Celerity.Language.Diagnostics.DiagnosticCode code) -> bool
static Vezel.Celerity.Language.ModulePath.Create(params string![]! components) -> Vezel.Celerity.Language.ModulePath!
static Vezel.Celerity.Language.ModulePath.Create(params System.ReadOnlySpan<string!> components) -> Vezel.Celerity.Language.ModulePath!
static Vezel.Celerity.Language.ModulePath.Create(System.Collections.Generic.IEnumerable<string!>! components) -> Vezel.Celerity.Language.ModulePath!
static Vezel.Celerity.Language.ModulePath.operator !=(Vezel.Celerity.Language.ModulePath? left, Vezel.Celerity.Language.ModulePath? right) -> bool
static Vezel.Celerity.Language.ModulePath.operator ==(Vezel.Celerity.Language.ModulePath? left, Vezel.Celerity.Language.ModulePath? right) -> bool
Expand All @@ -1073,7 +1073,7 @@ static Vezel.Celerity.Language.Quality.Passes.UnreachableCodePass.Instance.get -
static Vezel.Celerity.Language.Quality.Passes.UnusedLocalSymbolPass.Instance.get -> Vezel.Celerity.Language.Quality.Passes.UnusedLocalSymbolPass!
static Vezel.Celerity.Language.Quality.Passes.UppercaseBaseIndicatorPass.Instance.get -> Vezel.Celerity.Language.Quality.Passes.UppercaseBaseIndicatorPass!
static Vezel.Celerity.Language.Semantics.Binding.InteractiveContext.Default.get -> Vezel.Celerity.Language.Semantics.Binding.InteractiveContext!
static Vezel.Celerity.Language.Semantics.SemanticTree.Analyze(Vezel.Celerity.Language.Syntax.SyntaxTree! syntax, Vezel.Celerity.Language.Semantics.Binding.InteractiveContext? context, params Vezel.Celerity.Language.Semantics.DiagnosticAnalyzer![]! analyzers) -> Vezel.Celerity.Language.Semantics.SemanticTree!
static Vezel.Celerity.Language.Semantics.SemanticTree.Analyze(Vezel.Celerity.Language.Syntax.SyntaxTree! syntax, Vezel.Celerity.Language.Semantics.Binding.InteractiveContext? context, params System.ReadOnlySpan<Vezel.Celerity.Language.Semantics.DiagnosticAnalyzer!> analyzers) -> Vezel.Celerity.Language.Semantics.SemanticTree!
static Vezel.Celerity.Language.Semantics.SemanticTree.Analyze(Vezel.Celerity.Language.Syntax.SyntaxTree! syntax, Vezel.Celerity.Language.Semantics.Binding.InteractiveContext? context, System.Collections.Generic.IEnumerable<Vezel.Celerity.Language.Semantics.DiagnosticAnalyzer!>! analyzers) -> Vezel.Celerity.Language.Semantics.SemanticTree!
static Vezel.Celerity.Language.StandardDiagnosticCodes.DuplicateAggregateExpressionField.get -> Vezel.Celerity.Language.Diagnostics.DiagnosticCode
static Vezel.Celerity.Language.StandardDiagnosticCodes.DuplicateAggregatePatternField.get -> Vezel.Celerity.Language.Diagnostics.DiagnosticCode
Expand Down Expand Up @@ -1202,7 +1202,7 @@ Vezel.Celerity.Language.Quality.LintPass.Code.get -> Vezel.Celerity.Language.Dia
Vezel.Celerity.Language.Quality.LintPass.LintPass(string! code) -> void
Vezel.Celerity.Language.Quality.LintPassContext
Vezel.Celerity.Language.Quality.LintPassContext.AddDiagnostic(Vezel.Celerity.Language.Diagnostics.Diagnostic! diagnostic) -> void
Vezel.Celerity.Language.Quality.LintPassContext.ReportDiagnostic(Vezel.Celerity.Language.Text.SourceTextSpan span, string! message, params (Vezel.Celerity.Language.Text.SourceTextSpan Span, string! Message)[]! notes) -> void
Vezel.Celerity.Language.Quality.LintPassContext.ReportDiagnostic(Vezel.Celerity.Language.Text.SourceTextSpan span, string! message, params System.ReadOnlySpan<(Vezel.Celerity.Language.Text.SourceTextSpan Span, string! Message)> notes) -> void
Vezel.Celerity.Language.Quality.LintPassContext.ReportDiagnostic(Vezel.Celerity.Language.Text.SourceTextSpan span, string! message, System.Collections.Generic.IEnumerable<(Vezel.Celerity.Language.Text.SourceTextSpan Span, string! Message)>! notes) -> void
Vezel.Celerity.Language.Quality.LintPassContext.Root.get -> Vezel.Celerity.Language.Semantics.Tree.DocumentSemantics!
Vezel.Celerity.Language.Quality.Passes.TestWithoutAssertPass
Expand Down Expand Up @@ -1230,7 +1230,7 @@ Vezel.Celerity.Language.Semantics.DiagnosticAnalyzer
Vezel.Celerity.Language.Semantics.DiagnosticAnalyzer.DiagnosticAnalyzer() -> void
Vezel.Celerity.Language.Semantics.DiagnosticAnalyzerContext
Vezel.Celerity.Language.Semantics.DiagnosticAnalyzerContext.AddDiagnostic(Vezel.Celerity.Language.Diagnostics.Diagnostic! diagnostic) -> void
Vezel.Celerity.Language.Semantics.DiagnosticAnalyzerContext.ReportDiagnostic(Vezel.Celerity.Language.Text.SourceTextSpan span, Vezel.Celerity.Language.Diagnostics.DiagnosticSeverity severity, Vezel.Celerity.Language.Diagnostics.DiagnosticCode code, string! message, params (Vezel.Celerity.Language.Text.SourceTextSpan Span, string! Message)[]! notes) -> void
Vezel.Celerity.Language.Semantics.DiagnosticAnalyzerContext.ReportDiagnostic(Vezel.Celerity.Language.Text.SourceTextSpan span, Vezel.Celerity.Language.Diagnostics.DiagnosticSeverity severity, Vezel.Celerity.Language.Diagnostics.DiagnosticCode code, string! message, params System.ReadOnlySpan<(Vezel.Celerity.Language.Text.SourceTextSpan Span, string! Message)> notes) -> void
Vezel.Celerity.Language.Semantics.DiagnosticAnalyzerContext.ReportDiagnostic(Vezel.Celerity.Language.Text.SourceTextSpan span, Vezel.Celerity.Language.Diagnostics.DiagnosticSeverity severity, Vezel.Celerity.Language.Diagnostics.DiagnosticCode code, string! message, System.Collections.Generic.IEnumerable<(Vezel.Celerity.Language.Text.SourceTextSpan Span, string! Message)>! notes) -> void
Vezel.Celerity.Language.Semantics.DiagnosticAnalyzerContext.Root.get -> Vezel.Celerity.Language.Semantics.Tree.DocumentSemantics!
Vezel.Celerity.Language.Semantics.SemanticTree
Expand Down
4 changes: 2 additions & 2 deletions src/language/core/Quality/LintPassContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ internal void Invalidate()
}

public void ReportDiagnostic(
SourceTextSpan span, string message, params (SourceTextSpan Span, string Message)[] notes)
SourceTextSpan span, string message, params ReadOnlySpan<(SourceTextSpan Span, string Message)> notes)
{
ReportDiagnostic(span, message, notes.AsEnumerable());
ReportDiagnostic(span, message, notes.ToArray().AsEnumerable());
}

public void ReportDiagnostic(
Expand Down
4 changes: 2 additions & 2 deletions src/language/core/Semantics/DiagnosticAnalyzerContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ public void ReportDiagnostic(
DiagnosticSeverity severity,
DiagnosticCode code,
string message,
params (SourceTextSpan Span, string Message)[] notes)
params ReadOnlySpan<(SourceTextSpan Span, string Message)> notes)
{
ReportDiagnostic(span, severity, code, message, notes.AsEnumerable());
ReportDiagnostic(span, severity, code, message, notes.ToArray().AsEnumerable());
}

public void ReportDiagnostic(
Expand Down
4 changes: 2 additions & 2 deletions src/language/core/Semantics/SemanticTree.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ private SemanticTree(SyntaxTree syntax, DocumentSemantics root, ImmutableArray<D
}

public static SemanticTree Analyze(
SyntaxTree syntax, InteractiveContext? context, params DiagnosticAnalyzer[] analyzers)
SyntaxTree syntax, InteractiveContext? context, params ReadOnlySpan<DiagnosticAnalyzer> analyzers)
{
return Analyze(syntax, context, analyzers.AsEnumerable());
return Analyze(syntax, context, analyzers.ToArray().AsEnumerable());
}

public static SemanticTree Analyze(
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/core/Native/RuntimeInterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ static RuntimeInterop()
? $"lib{name}.dylib"
: $"lib{name}.so";
bool TryLoad(out nint handle, params string[] paths)
bool TryLoad(out nint handle, params ReadOnlySpan<string> paths)
{
return NativeLibrary.TryLoad(Path.Combine([directory, .. paths, fileName]), out handle);
}
Expand Down

0 comments on commit da75bf4

Please sign in to comment.