Skip to content

Commit

Permalink
Reduce allocations in TcPatBindingName
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Oct 1, 2018
1 parent 0eb2f9f commit 6ca1079
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
3 changes: 0 additions & 3 deletions src/fsharp/NameResolution.fs
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,6 @@ let private AddPartsOfTyconRefToNameEnv bulkAddMode ownDefinition (g:TcGlobals)
eIndexedExtensionMembers = eIndexedExtensionMembers
eUnindexedExtensionMembers = eUnindexedExtensionMembers }

let TryFindPatternByName name {ePatItems = patternMap} =
NameMap.tryFind name patternMap

/// Add a set of type definitions to the name resolution environment
let AddTyconRefsToNameEnv bulkAddMode ownDefinition g amap m root nenv tcrefs =
if isNil tcrefs then nenv else
Expand Down
3 changes: 0 additions & 3 deletions src/fsharp/NameResolution.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,6 @@ type FullyQualifiedFlag =
[<RequireQualifiedAccess>]
type BulkAdd = Yes | No

/// Lookup patterns in name resolution environment
val internal TryFindPatternByName : string -> NameResolutionEnv -> Item option

/// Add extra items to the environment for Visual Studio, e.g. static members
val internal AddFakeNamedValRefToNameEnv : string -> NameResolutionEnv -> ValRef -> NameResolutionEnv

Expand Down
6 changes: 3 additions & 3 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -5106,10 +5106,10 @@ and TcPatBindingName cenv env id ty isMemberThis vis1 topValData (inlineFlag, de
| Some value ->
let name = id.idText
if not (String.IsNullOrEmpty name) && Char.IsLower(name.[0]) then
match TryFindPatternByName name env.eNameResEnv with
| Some (Item.Value vref) when vref.LiteralValue.IsSome ->
match env.eNameResEnv.ePatItems.TryGetValue name with
| true, Item.Value vref when vref.LiteralValue.IsSome ->
warning(Error(FSComp.SR.checkLowercaseLiteralBindingInPattern(id.idText), id.idRange))
| Some _ | None -> ()
| _ -> ()
value
| None -> error(Error(FSComp.SR.tcNameNotBoundInPattern(id.idText), id.idRange))

Expand Down

0 comments on commit 6ca1079

Please sign in to comment.