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

Delta Between Two Patch Sets: src/pkg/os/file_windows.go

Issue 6523043: code review 6523043: os: use small writes during console io (Closed)
Left Patch Set: diff -r 195e4fc09b2d https://go.googlecode.com/hg/ Created 11 years, 6 months ago
Right Patch Set: diff -r 7cbb8aa08f8e https://go.googlecode.com/hg/ Created 11 years, 6 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/os/os_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 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 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 package os 5 package os
6 6
7 import ( 7 import (
8 "io" 8 "io"
9 "runtime" 9 "runtime"
10 "sync" 10 "sync"
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 } 251 }
252 for len(b) >= utf8.UTFMax || utf8.FullRune(b) { 252 for len(b) >= utf8.UTFMax || utf8.FullRune(b) {
253 r, l := utf8.DecodeRune(b) 253 r, l := utf8.DecodeRune(b)
254 runes = append(runes, r) 254 runes = append(runes, r)
255 b = b[l:] 255 b = b[l:]
256 } 256 }
257 if len(b) > 0 { 257 if len(b) > 0 {
258 f.lastbits = make([]byte, len(b)) 258 f.lastbits = make([]byte, len(b))
259 copy(f.lastbits, b) 259 copy(f.lastbits, b)
260 } 260 }
261 // syscall.WriteConsole seems to fail, if given large buffer.
262 // So limit the buffer to 16000 characters. This number was
263 // discovered by experimenting with syscall.WriteConsole.
261 const maxWrite = 16000 264 const maxWrite = 16000
262 for len(runes) > 0 { 265 for len(runes) > 0 {
263 m := len(runes) 266 m := len(runes)
264 if m > maxWrite { 267 if m > maxWrite {
265 m = maxWrite 268 m = maxWrite
266 } 269 }
267 chunk := runes[:m] 270 chunk := runes[:m]
268 runes = runes[m:] 271 runes = runes[m:]
269 uint16s := utf16.Encode(chunk) 272 uint16s := utf16.Encode(chunk)
270 for len(uint16s) > 0 { 273 for len(uint16s) > 0 {
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
399 n, _ = syscall.GetTempPath(uint32(len(dirw)), &dirw[0]) 402 n, _ = syscall.GetTempPath(uint32(len(dirw)), &dirw[0])
400 if n > uint32(len(dirw)) { 403 if n > uint32(len(dirw)) {
401 n = 0 404 n = 0
402 } 405 }
403 } 406 }
404 if n > 0 && dirw[n-1] == pathSep { 407 if n > 0 && dirw[n-1] == pathSep {
405 n-- 408 n--
406 } 409 }
407 return string(utf16.Decode(dirw[0:n])) 410 return string(utf16.Decode(dirw[0:n]))
408 } 411 }
LEFTRIGHT

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