Skip to content

Commit

Permalink
cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubmisek committed May 9, 2024
1 parent d8f7544 commit a861c32
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
8 changes: 4 additions & 4 deletions src/Peachpie.CodeAnalysis/Semantics/SemanticsBinder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Devsense.PHP.Text;
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.Operations;
using Microsoft.CodeAnalysis.PooledObjects;
using Pchp.CodeAnalysis.Symbols;
using Roslyn.Utilities;
using System;
Expand All @@ -10,7 +11,6 @@
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AST = Devsense.PHP.Syntax.Ast;
using Pchp.CodeAnalysis.Semantics.Graph;
using Pchp.CodeAnalysis.FlowAnalysis;
Expand Down Expand Up @@ -1095,8 +1095,8 @@ protected ImmutableArray<BoundArrayItem> BindArrayItems(ReadOnlySpan<AST.Item> i
return ImmutableArray<BoundArrayItem>.Empty;
}

var builder = ImmutableArray.CreateBuilder<BoundArrayItem>(items.Length);

var builder = ArrayBuilder<BoundArrayItem>.GetInstance();
foreach (var x in items)
{
if (x == null)
Expand Down Expand Up @@ -1124,7 +1124,7 @@ protected ImmutableArray<BoundArrayItem> BindArrayItems(ReadOnlySpan<AST.Item> i
}

//
return builder.ToImmutable();
return builder.ToImmutableAndFree();
}

protected BoundExpression BindItemUse(AST.ItemUse x, BoundAccess access)
Expand Down
6 changes: 2 additions & 4 deletions src/Peachpie.CodeAnalysis/Symbols/PE/PENamedTypeSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -980,15 +980,13 @@ public override ImmutableArray<Symbol> GetMembers(string name)
{
EnsureAllMembersAreLoaded();

ImmutableArray<Symbol> m;
if (!_lazyMembersByName.TryGetValue(name, out m))
if (!_lazyMembersByName.TryGetValue(name, out var m))
{
m = ImmutableArray<Symbol>.Empty;
}

// nested types are not common, but we need to check just in case
ImmutableArray<PENamedTypeSymbol> t;
if (_lazyNestedTypes.TryGetValue(name, out t))
if (_lazyNestedTypes.TryGetValue(name, out var t))
{
m = m.Concat(StaticCast<Symbol>.From(t));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,8 @@ public sealed override ImmutableArray<Symbol> GetMembers(string name)
{
if (_unbound) return StaticCast<Symbol>.From(GetTypeMembers(name));

ImmutableArray<Symbol> result;
var cache = _lazyMembersByNameCache;
if (cache != null && cache.TryGetValue(name, out result))
if (cache != null && cache.TryGetValue(name, out var result))
{
return result;
}
Expand Down

0 comments on commit a861c32

Please sign in to comment.