File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -106,10 +106,9 @@ public enum SyntaxParser {
106
106
public static func parse( _ url: URL ,
107
107
diagnosticEngine: DiagnosticEngine ? = nil ) throws -> SourceFileSyntax {
108
108
// Avoid using `String(contentsOf:)` because it creates a wrapped NSString.
109
- var fileData = try Data ( contentsOf: url)
110
- fileData. append ( 0 ) // null terminate.
111
- let source = fileData. withUnsafeBytes { ( ptr: UnsafePointer < CChar > ) in
112
- return String ( cString: ptr)
109
+ let fileData = try Data ( contentsOf: url)
110
+ let source = fileData. withUnsafeBytes { buf in
111
+ return String . fromBuffer ( buf. bindMemory ( to: UInt8 . self) )
113
112
}
114
113
return try parse ( source: source, filenameForDiagnostics: url. absoluteString,
115
114
diagnosticEngine: diagnosticEngine)
You can’t perform that action at this time.
0 commit comments