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

Commit8114be5

Browse files
committed
Merge branch 'master' into fsharp4
Conflicts:src/fsharp/FSharp.Core/array.fssrc/fsharp/FSharp.Core/local.fssrc/fsharp/FSharp.Core/local.fsi
2 parentsb148529 +2e1f4db commit8114be5

File tree

5 files changed

+91
-86
lines changed

5 files changed

+91
-86
lines changed

‎src/absil/il.fs‎

Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -198,15 +198,15 @@ let b3 n = ((n >>> 24) &&& 0xFF)
198198
moduleSHA1=
199199
let inline(>>>&)(x:int)(y:int)= int32(uint32 x>>> y)
200200
letf(t,b,c,d)=
201-
if t<20then(b&&& c)|||((~~~b)&&& d)else
202-
if t<40then b^^^ c^^^ delse
203-
if t<60then(b&&& c)|||(b&&& d)|||(c&&& d)else
204-
b^^^ c^^^ d
201+
if t<20then(b&&& c)|||((~~~b)&&& d)
202+
elif t<40then b^^^ c^^^ d
203+
elif t<60then(b&&& c)|||(b&&& d)|||(c&&& d)
204+
elseb^^^ c^^^ d
205205

206-
letk0to19=0x5A827999
207-
letk20to39=0x6ED9EBA1
208-
letk40to59=0x8F1BBCDC
209-
letk60to79=0xCA62C1D6
206+
let[<Literal>]k0to19=0x5A827999
207+
let[<Literal>]k20to39=0x6ED9EBA1
208+
let[<Literal>]k40to59=0x8F1BBCDC
209+
let[<Literal>]k60to79=0xCA62C1D6
210210

211211
letk t=
212212
if t<20then k0to19
@@ -223,7 +223,7 @@ module SHA1 =
223223

224224
letrot_left32 x n=(x<<< n)|||(x>>>&(32-n))
225225

226-
letsha_eof sha= sha.eof
226+
letinlinesha_eof sha= sha.eof
227227

228228
(* padding and length (in bits!) recorded at end*)
229229
letsha_after_eof sha=
@@ -260,43 +260,41 @@ module SHA1 =
260260
letres=(b0<<<24)|||(b1<<<16)|||(b2<<<8)||| b3
261261
res
262262

263-
264263
letsha1_hash sha=
265-
leth0= ref0x67452301
266-
leth1= ref0xEFCDAB89
267-
leth2= ref0x98BADCFE
268-
leth3= ref0x10325476
269-
leth4= ref0xC3D2E1F0
270-
leta= ref0
271-
letb= ref0
272-
letc= ref0
273-
letd= ref0
274-
lete= ref0
264+
letmutableh0=0x67452301
265+
letmutableh1=0xEFCDAB89
266+
letmutableh2=0x98BADCFE
267+
letmutableh3=0x10325476
268+
letmutableh4=0xC3D2E1F0
269+
letmutablea=0
270+
letmutableb=0
271+
letmutablec=0
272+
letmutabled=0
273+
letmutablee=0
275274
letw= Array.create800x00
276275
while(not(sha_eof sha))do
277-
for i=0to15do
278-
w.[i]<- sha_read32 sha
279-
for t=16to79do
280-
w.[t]<- rot_left32(w.[t-3]^^^ w.[t-8]^^^ w.[t-14]^^^ w.[t-16])1;
281-
a:=!h0;
282-
b:=!h1;
283-
c:=!h2;
284-
d:=!h3;
285-
e:=!h4;
286-
for t=0to79do
287-
lettemp=(rot_left32!a5)+ f(t,!b,!c,!d)+!e+ w.[t]+ k(t)
288-
e:=!d;
289-
d:=!c;
290-
c:= rot_left32!b30;
291-
b:=!a;
292-
a:= temp;
293-
h0:=!h0+!a;
294-
h1:=!h1+!b;
295-
h2:=!h2+!c;
296-
h3:=!h3+!d;
297-
h4:=!h4+!e
298-
done;
299-
(!h0,!h1,!h2,!h3,!h4)
276+
for i=0to15do
277+
w.[i]<- sha_read32 sha
278+
for t=16to79do
279+
w.[t]<- rot_left32(w.[t-3]^^^ w.[t-8]^^^ w.[t-14]^^^ w.[t-16])1
280+
a<- h0
281+
b<- h1
282+
c<- h2
283+
d<- h3
284+
e<- h4
285+
for t=0to79do
286+
lettemp=(rot_left32 a5)+ f(t,b,c,d)+ e+ w.[t]+ k(t)
287+
e<- d
288+
d<- c
289+
c<- rot_left32 b30
290+
b<- a
291+
a<- temp
292+
h0<- h0+ a
293+
h1<- h1+ b
294+
h2<- h2+ c
295+
h3<- h3+ d
296+
h4<- h4+ e
297+
h0,h1,h2,h3,h4
300298

301299
letsha1HashBytes s=
302300
let(_h0,_h1,_h2,h3,h4)= sha1_hash{ stream= SHABytes s; pos=0; eof=false}// the result of the SHA algorithm is stored in registers 3 and 4

‎src/fsharp/FSharp.Core/array.fs‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -937,11 +937,7 @@ namespace Microsoft.FSharp.Collections
937937
if startIndex<0then invalidArg"startIndex"(SR.GetString(SR.inputMustBeNonNegative))
938938
if count<0then invalidArg"count"(SR.GetString(SR.inputMustBeNonNegative))
939939
if startIndex+ count> array.Lengththen invalidArg"count"(SR.GetString(SR.outOfRange))
940-
941-
letres=(Microsoft.FSharp.Primitives.Basics.Array.zeroCreateUnchecked count: 'T[])
942-
for i=0to count-1do
943-
res.[i]<- array.[startIndex+ i]
944-
res
940+
Microsoft.FSharp.Primitives.Basics.Array.subUnchecked startIndex count array
945941

946942
[<CompiledName("Item")>]
947943
letitem n(array:_[])=

‎src/fsharp/FSharp.Core/local.fs‎

Lines changed: 43 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -274,18 +274,44 @@ module internal List =
274274
concatToFreshConsTail res t1 tt2;
275275
res
276276

277-
letseqToList(e:IEnumerable<'T>)=
278-
match ewith
277+
lettoArray(l:'T list)=
278+
letlen= l.Length
279+
letres= arrayZeroCreate len
280+
let recloop i l=
281+
match lwith
282+
|[]->()
283+
| h::t->
284+
res.[i]<- h
285+
loop(i+1) t
286+
loop0 l
287+
res
288+
289+
letofArray(arr:'T[])=
290+
letlen= arr.Length
291+
let mutableres=([]: 'T list)
292+
for i= len-1downto0do
293+
res<- arr.[i]:: res
294+
res
295+
296+
let inlineofSeq(e:IEnumerable<'T>)=
297+
match ewith
279298
|:? list<'T>as l-> l
280-
|_->
299+
|:?('T[])as arr-> ofArray arr
300+
|_->
281301
use ie= e.GetEnumerator()
282-
let mutableres=[]
283-
while ie.MoveNext()do
284-
res<- ie.Current:: res
285-
rev res
302+
ifnot(ie.MoveNext())then[]
303+
else
304+
letres= freshConsNoTail ie.Current
305+
let mutablecons= res
306+
while ie.MoveNext()do
307+
letcons2= freshConsNoTail ie.Current
308+
setFreshConsTail cons cons2
309+
cons<- cons2
310+
setFreshConsTail cons[]
311+
res
286312

287313
letconcat(l:seq<_>)=
288-
matchseqToList lwith
314+
matchofSeq lwith
289315
|[]->[]
290316
|[h]-> h
291317
|[h1;h2]-> h1@ h2
@@ -583,25 +609,6 @@ module internal List =
583609
|_->
584610
invalidArg"xs1"(SR.GetString(SR.listsHadDifferentLengths))
585611

586-
lettoArray(l:'T list)=
587-
letlen= l.Length
588-
letres= arrayZeroCreate len
589-
let recloop i l=
590-
match lwith
591-
|[]->()
592-
| h::t->
593-
res.[i]<- h
594-
loop(i+1) t
595-
loop0 l
596-
res
597-
598-
letofArray(arr:'T[])=
599-
letlen= arr.Length
600-
let mutableres=([]: 'T list)
601-
for i= len-1downto0do
602-
res<- arr.[i]:: res
603-
res
604-
605612
let rectakeWhileFreshConsTail cons p l=
606613
match lwith
607614
|[]-> setFreshConsTail cons[]
@@ -917,3 +924,12 @@ module internal Array =
917924
// 'keys' is an array storing the projected keys
918925
letkeys=(array.Clone():?> array<'T>)
919926
stableSortWithKeys array keys
927+
928+
let inlinesubUnchecked startIndex count(array:'T[])=
929+
letres= zeroCreateUnchecked count: 'T[]
930+
if count<64then
931+
for i=0to count-1do
932+
res.[i]<- array.[startIndex+i]
933+
else
934+
Array.Copy(array, startIndex, res,0, count)
935+
res

‎src/fsharp/FSharp.Core/local.fsi‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ module internal List =
3434
val take: int-> 'T list-> 'T list
3535
val takeWhile:('T-> bool)-> 'T list-> 'T list
3636
val toArray: 'T list-> 'T[]
37+
val inline ofSeq: seq<'T>-> 'T List
3738
val sortWith:('T-> 'T-> int)-> 'T list-> 'T list
3839
val splitAt: int-> 'T list->('T list* 'T list)
3940
val truncate: int-> 'T list-> 'T list
@@ -57,9 +58,11 @@ module internal Array =
5758
val mapFoldBack:('T-> 'State-> 'U* 'State)-> 'T[]-> 'State-> 'U[]* 'State
5859

5960
val permute: indexMap:(int-> int)-> 'T[]-> 'T[]
60-
61+
6162
val scanSubRight: f:('T-> 'State-> 'State)-> array:'T[]-> start:int-> fin:int-> initState:'State-> 'State[]
6263

64+
val inline subUnchecked: int-> int-> 'T[]-> 'T[]
65+
6366
val unstableSortInPlaceBy: projection:('T-> 'Key)-> array:'T[]-> unit when 'Key: comparison
6467

6568
val unstableSortInPlace: array:'T[]-> unit when 'T: comparison

‎src/fsharp/FSharp.Core/seq.fs‎

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,17 +1215,9 @@ namespace Microsoft.FSharp.Collections
12151215
(source:> seq<'T>)
12161216

12171217
[<CompiledName("ToList")>]
1218-
lettoList(source:seq<'T>)=
1218+
lettoList(source:seq<'T>)=
12191219
checkNonNull"source" source
1220-
match sourcewith
1221-
|:?('T list)as res-> res
1222-
|:?('T[])as res-> List.ofArray res
1223-
|_->
1224-
use e= source.GetEnumerator()
1225-
let mutableres=[]
1226-
while e.MoveNext()do
1227-
res<- e.Current:: res
1228-
List.rev res
1220+
Microsoft.FSharp.Primitives.Basics.List.ofSeq source
12291221

12301222
// Create a new object to ensure underlying array may not be mutated by a backdoor cast
12311223
[<CompiledName("OfArray")>]

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp