autogenerated_exclude: increase scanner buffer (#955)
* autogenerated_exclude: increase scanner buffer Some lines can be very long, so increase scanner buffer to mitigate this. Fix #954
This commit is contained in:
		
							parent
							
								
									4d165fc2dd
								
							
						
					
					
						commit
						18ab7a0005
					
				| @ -120,6 +120,15 @@ func getDoc(filePath string) (string, error) { | |||||||
| 	defer file.Close() | 	defer file.Close() | ||||||
| 
 | 
 | ||||||
| 	scanner := bufio.NewScanner(file) | 	scanner := bufio.NewScanner(file) | ||||||
|  | 
 | ||||||
|  | 	// Issue 954: Some lines can be very long, e.g. auto-generated | ||||||
|  | 	// embedded resources. Reported on file of 86.2KB. | ||||||
|  | 	const ( | ||||||
|  | 		maxSize     = 512 * 1024 // 512KB should be enough | ||||||
|  | 		initialSize = 4096       // same as startBufSize in bufio | ||||||
|  | 	) | ||||||
|  | 	scanner.Buffer(make([]byte, initialSize), maxSize) | ||||||
|  | 
 | ||||||
| 	var docLines []string | 	var docLines []string | ||||||
| 	for scanner.Scan() { | 	for scanner.Scan() { | ||||||
| 		line := strings.TrimSpace(scanner.Text()) | 		line := strings.TrimSpace(scanner.Text()) | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Aleksandr Razumov
						Aleksandr Razumov