Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitd7274c6

Browse files
forkidsyme
authored andcommitted
Clean up illib (dotnet#4428)
* clean option module in illib* Update NicePrint.fs* Update NicePrint.fs* Update NicePrint.fs* Update NicePrint.fs* Update NicePrint.fs
1 parent3fb44a4 commitd7274c6

File tree

5 files changed

+22
-61
lines changed

5 files changed

+22
-61
lines changed

‎src/absil/illib.fs‎

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ let inline isSingleton l =
3737

3838
let inlineisNonNull x=not(isNull x)
3939
let inlinenonNull msg x=if isNull xthen failwith("null:"^ msg)else x
40-
let(===) x y= LanguagePrimitives.PhysicalEquality x y
40+
letinline(===) x y= LanguagePrimitives.PhysicalEquality x y
4141

4242
//---------------------------------------------------------------------
4343
// Library: ReportTime
4444
//---------------------------------------------------------------------
4545
letreportTime=
46-
lettFirst= ref None
47-
lettPrev= ref None
46+
lettFirst= ref None
47+
lettPrev= ref None
4848
fun showTimes descr->
4949
if showTimesthen
5050
lett= System.Diagnostics.Process.GetCurrentProcess().UserProcessorTime.TotalSeconds
@@ -237,36 +237,12 @@ module Option =
237237
letmapFold f s opt=
238238
match optwith
239239
| None-> None,s
240-
| Some x->letx',s'= f s xin Some x',s'
241-
242-
letotherwise opt dflt=
243-
match optwith
244-
| None-> dflt
245-
| Some x-> x
246-
247-
letfold f z x=
248-
match xwith
249-
| None-> z
250-
| Some x-> f z x
251-
252-
letattempt(f:unit->'T)=try Some(f())with_-> None
253-
254-
255-
letorElseWith f opt=
256-
match optwith
257-
| None-> f()
258-
| x-> x
259-
260-
letorElse v opt=
261-
match optwith
262-
| None-> v
263-
| x-> x
264-
265-
letdefaultValue v opt=
266-
match optwith
267-
| None-> v
268-
| Some x-> x
240+
| Some x->
241+
letx',s'= f s x
242+
Some x',s'
269243

244+
letattempt(f:unit->'T)=try Some(f())with_-> None
245+
270246
moduleList=
271247

272248
//let item n xs = List.nth xs n
@@ -442,9 +418,6 @@ module List =
442418
| x::xs->if i=nthen f x::xselse x::mn(i+1) xs
443419

444420
mn0 xs
445-
446-
let recuntil p l=match lwith[]->[]| h::t->if p hthen[]else h:: until p t
447-
448421
letcount pred xs= List.fold(fun n x->if pred xthen n+1else n)0 xs
449422

450423
// WARNING: not tail-recursive
@@ -521,23 +494,9 @@ module String =
521494
if s.Length=0then s
522495
else lowercase s.[0..0]+ s.[1.. s.Length-1]
523496

497+
letdropPrefix(s:string)(t:string)= s.[t.Length..s.Length-1]
524498

525-
lettryDropPrefix(s:string)(t:string)=
526-
if s.StartsWith tthen
527-
Some s.[t.Length..s.Length-1]
528-
else
529-
None
530-
531-
lettryDropSuffix(s:string)(t:string)=
532-
if s.EndsWith tthen
533-
Some s.[0..s.Length- t.Length-1]
534-
else
535-
None
536-
537-
lethasPrefix s t= Option.isSome(tryDropPrefix s t)
538-
letdropPrefix s t=match(tryDropPrefix s t)with Some(res)-> res| None-> failwith"dropPrefix"
539-
540-
letdropSuffix s t=match(tryDropSuffix s t)with Some(res)-> res| None-> failwith"dropSuffix"
499+
letdropSuffix(s:string)(t:string)= s.[0..s.Length- t.Length-1]
541500

542501
openSystem
543502
openSystem.IO

‎src/fsharp/NicePrint.fs‎

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,10 @@ module internal PrintUtilities =
7171
tcref.DisplayName// has no static params
7272
else
7373
tcref.DisplayName+"<...>"// shorten
74-
if isAttributethen
75-
defaultArg(String.tryDropSuffix name"Attribute") name
76-
else name
74+
if isAttribute&& name.EndsWith"Attribute"then
75+
String.dropSuffix name"Attribute"
76+
else
77+
name
7778
lettyconTextL=
7879
tagEntityRefName tcref demangled
7980
|> mkNav tcref.DefinitionRange
@@ -654,9 +655,10 @@ module private PrintTypes =
654655
| ILAttrib ilMethRef->
655656
lettrimmedName=
656657
letname= ilMethRef.DeclaringTypeRef.Name
657-
match String.tryDropSuffix name"Attribute"with
658-
| Some shortName-> shortName
659-
| None-> name
658+
if name.EndsWith"Attribute"then
659+
String.dropSuffix name"Attribute"
660+
else
661+
name
660662
lettref= ilMethRef.DeclaringTypeRef
661663
lettref= ILTypeRef.Create(scope= tref.Scope, enclosing=tref.Enclosing, name=trimmedName)
662664
PrintIL.layoutILTypeRef denv tref++ argsL
@@ -1275,7 +1277,7 @@ module InfoMemberPrinting =
12751277
letparamDatas= minfo.GetParamDatas(amap, m, minst)
12761278
letlayout=
12771279
layout^^
1278-
ifisNil(List.concatparamDatas)then
1280+
if List.forall isNilparamDatasthen
12791281
WordL.structUnit
12801282
else
12811283
sepListL WordL.arrow(List.map((List.map(layoutParamData denv))>> sepListL WordL.star) paramDatas)

‎src/fsharp/TastOps.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1451,7 +1451,7 @@ let tryDestRefTupleTy g ty =
14511451
typeUncurriedArgInfos=(TType* ArgReprInfo) list
14521452
typeCurriedArgInfos=(TType* ArgReprInfo) list list
14531453

1454-
// A 'tau' type is one with its typeparamaeters stripped off
1454+
// A 'tau' type is one with its typeparameters stripped off
14551455
letGetTopTauTypeInFSharpForm g(curriedArgInfos:ArgReprInfo list list)tau m=
14561456
letnArgInfos= curriedArgInfos.Length
14571457
letargtys,rty= stripFunTyN g nArgInfos tau

‎src/fsharp/TypeChecker.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5112,7 +5112,7 @@ and TcPatBindingName cenv env id ty isMemberThis vis1 topValData (inlineFlag, de
51125112
// isLeftMost indicates we are processing the left-most path through a disjunctive or pattern.
51135113
// For those binding locations, CallNameResolutionSink is called in MakeAndPublishValue, like all other bindings
51145114
// For non-left-most paths, we register the name resolutions here
5115-
if not isLeftMost && not vspec.IsCompilerGenerated && not (String.hasPrefixvspec.LogicalName "_") then
5115+
if not isLeftMost && not vspec.IsCompilerGenerated && not (vspec.LogicalName.StartsWith "_") then
51165116
let item = Item.Value(mkLocalValRef vspec)
51175117
CallNameResolutionSink cenv.tcSink (id.idRange, env.NameEnv, item, item, emptyTyparInst, ItemOccurence.Binding, env.DisplayEnv, env.eAccessRights)
51185118

‎src/fsharp/ast.fs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ type XmlDoc =
100100
|(lineA::rest)as lines->
101101
letlineAT= lineA.TrimStart([|' '|])
102102
if lineAT=""then processLines rest
103-
elseifString.hasPrefixlineAT"<"then lines
103+
elseif lineAT.StartsWith"<"then lines
104104
else["<summary>"]@
105105
(lines|> List.map(fun line-> Microsoft.FSharp.Core.XmlAdapters.escape(line)))@
106106
["</summary>"]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp