Repository navigation
Scanner(unification) + TryPeek #1463
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
f63a208
deacf9f
7d6acdb
6fec504
b401f40
cc616ed
a58d3f7
711246e
1bb3643
886f0f6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,7 @@ | ||
| ' Copyright (c) Microsoft. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
|
||
| '----------------------------------------------------------------------------- | ||
| ' Contains the definition of the Scanner, which produces tokens from text | ||
| ' Contains the definition of the Scanner, which produces tokens from text | ||
| '----------------------------------------------------------------------------- | ||
| Option Strict On | ||
| Option Explicit On | ||
|
|
@@ -339,7 +339,7 @@ Namespace Microsoft.CodeAnalysis.VisualBasic | |
| End Function | ||
|
|
||
| ''' <summary> | ||
| ''' Creates a half width form Unicode character string. | ||
| ''' Creates a half width form Unicode character string. | ||
| ''' </summary> | ||
| ''' <param name="text">The text representing the original identifier. This can be in full width or half width Unicode form. </param> | ||
| ''' <returns>A string representing the text in a half width Unicode form.</returns> | ||
|
|
@@ -488,4 +488,38 @@ Namespace Microsoft.CodeAnalysis.VisualBasic | |
| End Function | ||
| End Class | ||
|
|
||
| Friend Module CharExts | ||
|
|
||
| <Runtime.CompilerServices.Extension> | ||
| Friend Function IsFrom(c As Char, c0 As Char, c1 As Char) As Boolean | ||
| Return (c = c0) OrElse (c = c1) | ||
| End Function | ||
|
|
||
| <Runtime.CompilerServices.Extension> | ||
| Friend Function IsFrom(c As Char, c0 As Char, c1 As Char, c2 As Char) As Boolean | ||
| Return (c = c0) OrElse (c = c1) OrElse (c = c2) | ||
| End Function | ||
|
|
||
| <Runtime.CompilerServices.Extension> | ||
| Friend Function IsFrom(c As Char, c0 As Char, c1 As Char, c2 As Char, c3 As Char) As Boolean | ||
| Return (c = c0) OrElse (c = c1) OrElse (c = c2) OrElse (c = c3) | ||
| End Function | ||
|
|
||
| <Runtime.CompilerServices.Extension> | ||
| Friend Function IsntFrom(c As Char, c0 As Char, c1 As Char) As Boolean | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Prefer
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So you are saying that there is occasions that you use contractions. The APIs isn't public. |
||
| Return (c <> c0) AndAlso (c <> c1) | ||
| End Function | ||
|
|
||
| <Runtime.CompilerServices.Extension> | ||
| Friend Function IsntFrom(c As Char, c0 As Char, c1 As Char, c2 As Char) As Boolean | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
| Return (c <> c0) AndAlso (c <> c1) AndAlso (c <> c2) | ||
| End Function | ||
|
|
||
| <Runtime.CompilerServices.Extension> | ||
| Friend Function IsntFrom(c As Char, c0 As Char, c1 As Char, c2 As Char, c3 As Char) As Boolean | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same |
||
| Return (c <> c0) AndAlso (c <> c1) AndAlso (c <> c2) AndAlso (c <> c3) | ||
| End Function | ||
|
|
||
| End Module | ||
|
|
||
| End Namespace | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OrElse seems unnecessary here. OR with unconditional extra char compare is likely to be cheaper than deciding whether to do it or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VSadov
The use of the
OrElseadds only 2 IL bytes per a usage. So don't think that cost isn't too much.