Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(841)

Delta Between Two Patch Sets: src/pkg/crypto/md5/gen.go

Issue 6782072: code review 6782072: crypto/md5: speed up aligned writes and test/bench unal... (Closed)
Left Patch Set: diff -r 591fc8a0131a https://code.google.com/p/go Created 11 years, 4 months ago
Right Patch Set: diff -r 5eee09217fcd https://code.google.com/p/go/ Created 11 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | src/pkg/crypto/md5/md5_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 // Copyright 2012 The Go Authors. All rights reserved. 1 // Copyright 2012 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // +build ignore 5 // +build ignore
6 6
7 // This program generates md5block.go 7 // This program generates md5block.go
8 // Invoke as 8 // Invoke as
9 // 9 //
10 // go run gen.go [-full] |gofmt >md5block.go 10 // go run gen.go [-full] |gofmt >md5block.go
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 for len(p) >= chunk { 196 for len(p) >= chunk {
197 aa, bb, cc, dd := a, b, c, d 197 aa, bb, cc, dd := a, b, c, d
198 198
199 // This is a constant condition - it is not evaluated on each it eration. 199 // This is a constant condition - it is not evaluated on each it eration.
200 if runtime.GOARCH == "amd64" || runtime.GOARCH == "386" { 200 if runtime.GOARCH == "amd64" || runtime.GOARCH == "386" {
201 // MD5 was designed so that x86 processors can just iter ate 201 // MD5 was designed so that x86 processors can just iter ate
202 // over the block data directly as uint32s, and we gener ate 202 // over the block data directly as uint32s, and we gener ate
203 // less code and run 1.3x faster if we take advantage of that. 203 // less code and run 1.3x faster if we take advantage of that.
204 // My apologies. 204 // My apologies.
205 X = (*[16]uint32)(unsafe.Pointer(&p[0])) 205 X = (*[16]uint32)(unsafe.Pointer(&p[0]))
206 » » } else if uintptr(unsafe.Pointer(&p[0])) & 3 == 0 { 206 » » } else if uintptr(unsafe.Pointer(&p[0]))&(unsafe.Alignof(uint32( 0))-1) == 0 {
207 X = (*[16]uint32)(unsafe.Pointer(&p[0])) 207 X = (*[16]uint32)(unsafe.Pointer(&p[0]))
208 } else { 208 } else {
209 X = &xbuf 209 X = &xbuf
210 j := 0 210 j := 0
211 for i := 0; i < 16; i++ { 211 for i := 0; i < 16; i++ {
212 X[i&15] = uint32(p[j]) | uint32(p[j+1])<<8 | uin t32(p[j+2])<<16 | uint32(p[j+3])<<24 212 X[i&15] = uint32(p[j]) | uint32(p[j+1])<<8 | uin t32(p[j+2])<<16 | uint32(p[j+3])<<24
213 j += 4 213 j += 4
214 } 214 }
215 } 215 }
216 216
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 291
292 p = p[chunk:] 292 p = p[chunk:]
293 } 293 }
294 294
295 dig.s[0] = a 295 dig.s[0] = a
296 dig.s[1] = b 296 dig.s[1] = b
297 dig.s[2] = c 297 dig.s[2] = c
298 dig.s[3] = d 298 dig.s[3] = d
299 } 299 }
300 ` 300 `
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b