Squashed 'third_party/flatbuffers/' changes from d6a8dbd26..338393f85

338393f85 Documentation updates for Optional Scalars (#6014) (#6270)
c27bc2d76 [C++] Add ParseJson(), Parser(Parser&&), update fuzzers (#6284)
bc518a512 Fixed FlexBufferBuilder asserting on duplicate keys
100c59054 Added a few more paths for auto labeler (#6281)
e58c18244 Add --require-explicit-ids to require explicit ids (#6277)
69a8b2a57 idl_gen_json_schema.cpp: Changed generation of array element types (#6253)
25eba6f35 fix typo (#6280)
e1f0f75ba Updated Ms build Action to fix build issue (#6279)
faeb04fbe Add type annotation to unspecified array (#6264)
537212afe [Swift] Adds a format file and reformats the swift project (#6250)
6764f25d9 Adds a fix for enum generation (#6263)

Change-Id: I716bd4d2521fb0a673e50a699cef761e042052b2
git-subtree-dir: third_party/flatbuffers
git-subtree-split: 338393f854eb5ba24761a22cd9316ff5cee4eab0
diff --git a/tests/FlatBuffers.Benchmarks.swift/Package.swift b/tests/FlatBuffers.Benchmarks.swift/Package.swift
index 9360b10..2026247 100644
--- a/tests/FlatBuffers.Benchmarks.swift/Package.swift
+++ b/tests/FlatBuffers.Benchmarks.swift/Package.swift
@@ -1,19 +1,32 @@
 // swift-tools-version:5.1
-// The swift-tools-version declares the minimum version of Swift required to build this package.
+/*
+ * Copyright 2020 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 
 import PackageDescription
 
 let package = Package(
-    name: "FlatBuffers.Benchmarks.swift",
-    platforms: [
-        .macOS(.v10_14)
-    ],
-    dependencies: [
-    .package(path: "../../swift")
-    ],
-    targets: [
-        .target(
-            name: "FlatBuffers.Benchmarks.swift",
-            dependencies: ["FlatBuffers"]),
-    ]
-)
+  name: "FlatBuffers.Benchmarks.swift",
+  platforms: [
+    .macOS(.v10_14),
+  ],
+  dependencies: [
+    .package(path: "../../swift"),
+  ],
+  targets: [
+    .target(
+      name: "FlatBuffers.Benchmarks.swift",
+      dependencies: ["FlatBuffers"]),
+  ])
diff --git a/tests/FlatBuffers.Benchmarks.swift/Sources/FlatBuffers.Benchmarks.swift/main.swift b/tests/FlatBuffers.Benchmarks.swift/Sources/FlatBuffers.Benchmarks.swift/main.swift
index e599c65..fed3f2d 100644
--- a/tests/FlatBuffers.Benchmarks.swift/Sources/FlatBuffers.Benchmarks.swift/main.swift
+++ b/tests/FlatBuffers.Benchmarks.swift/Sources/FlatBuffers.Benchmarks.swift/main.swift
@@ -1,104 +1,124 @@
+/*
+ * Copyright 2020 Google Inc. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
 import CoreFoundation
 import FlatBuffers
 
 struct Benchmark {
-    var name: String
-    var value: Double
-    
-    var description: String { "\(String(format: "|\t%@\t\t|\t\t%fs\t|", name, value))"}
+  var name: String
+  var value: Double
+
+  var description: String { "\(String(format: "|\t%@\t\t|\t\t%fs\t|", name, value))"}
 }
 
 func run(name: String, runs: Int, action: () -> Void) -> Benchmark {
+  action()
+  let start = CFAbsoluteTimeGetCurrent()
+  for _ in 0..<runs {
     action()
-    let start = CFAbsoluteTimeGetCurrent()
-    for _ in 0..<runs {
-        action()
-    }
-    let ends = CFAbsoluteTimeGetCurrent()
-    let value = Double(ends - start) / Double(runs)
-    print("done \(name): in \(value)")
-    return Benchmark(name: name, value: value)
+  }
+  let ends = CFAbsoluteTimeGetCurrent()
+  let value = Double(ends - start) / Double(runs)
+  print("done \(name): in \(value)")
+  return Benchmark(name: name, value: value)
 }
 
 
 func createDocument(Benchmarks: [Benchmark]) -> String {
-    let separator = "-------------------------------------"
-    var document = "\(separator)\n"
-    document += "\(String(format: "|\t%@\t\t|\t\t%@\t\t|", "Name", "Scores"))\n"
+  let separator = "-------------------------------------"
+  var document = "\(separator)\n"
+  document += "\(String(format: "|\t%@\t\t|\t\t%@\t\t|", "Name", "Scores"))\n"
+  document += "\(separator)\n"
+  for i in Benchmarks {
+    document += "\(i.description) \n"
     document += "\(separator)\n"
-    for i in Benchmarks {
-        document += "\(i.description) \n"
-        document += "\(separator)\n"
-    }
-    return document
+  }
+  return document
 }
 
-@inlinable func create10Strings() {
-    var fb = FlatBufferBuilder(initialSize: 1<<20)
-    for _ in 0..<10_000 {
-        _ = fb.create(string: "foobarbaz")
-    }
+@inlinable
+func create10Strings() {
+  var fb = FlatBufferBuilder(initialSize: 1<<20)
+  for _ in 0..<10_000 {
+    _ = fb.create(string: "foobarbaz")
+  }
 }
 
-@inlinable func create100Strings(str: String) {
-    var fb = FlatBufferBuilder(initialSize: 1<<20)
-    for _ in 0..<10_000 {
-        _ = fb.create(string: str)
-    }
+@inlinable
+func create100Strings(str: String) {
+  var fb = FlatBufferBuilder(initialSize: 1<<20)
+  for _ in 0..<10_000 {
+    _ = fb.create(string: str)
+  }
 }
 
-@inlinable func benchmarkFiveHundredAdds() {
-    var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
-    for _ in 0..<500_000 {
-        let off = fb.create(string: "T")
-        let s = fb.startTable(with: 4)
-        fb.add(element: 3.2, def: 0, at: 2)
-        fb.add(element: 4.2, def: 0, at: 4)
-        fb.add(element: 5.2, def: 0, at: 6)
-        fb.add(offset: off, at: 8)
-        _ = fb.endTable(at: s)
-    }
+@inlinable
+func benchmarkFiveHundredAdds() {
+  var fb = FlatBufferBuilder(initialSize: 1024 * 1024 * 32)
+  for _ in 0..<500_000 {
+    let off = fb.create(string: "T")
+    let s = fb.startTable(with: 4)
+    fb.add(element: 3.2, def: 0, at: 2)
+    fb.add(element: 4.2, def: 0, at: 4)
+    fb.add(element: 5.2, def: 0, at: 6)
+    fb.add(offset: off, at: 8)
+    _ = fb.endTable(at: s)
+  }
 }
 
-@inlinable func benchmarkThreeMillionStructs() {
-    let structCount = 3_000_000
-    
-    let rawSize = ((16 * 5) * structCount) / 1024
-    
-    var fb = FlatBufferBuilder(initialSize: Int32(rawSize * 1600))
-    
-    var offsets: [Offset<UOffset>] = []
-    for _ in 0..<structCount {
-        fb.startVectorOfStructs(count: 5, size: 16, alignment: 8)
-        for _ in 0..<5 {
-            fb.createStructOf(size: 16, alignment: 8)
-            fb.reverseAdd(v: 2.4, postion: 0)
-            fb.reverseAdd(v: 2.4, postion: 8)
-            fb.endStruct()
-        }
-        let vector = fb.endVectorOfStructs(count: 5)
-        let start = fb.startTable(with: 1)
-        fb.add(offset: vector, at: 4)
-        offsets.append(Offset<UOffset>(offset: fb.endTable(at: start)))
+@inlinable
+func benchmarkThreeMillionStructs() {
+  let structCount = 3_000_000
+
+  let rawSize = ((16 * 5) * structCount) / 1024
+
+  var fb = FlatBufferBuilder(initialSize: Int32(rawSize * 1600))
+
+  var offsets: [Offset<UOffset>] = []
+  for _ in 0..<structCount {
+    fb.startVectorOfStructs(count: 5, size: 16, alignment: 8)
+    for _ in 0..<5 {
+      fb.createStructOf(size: 16, alignment: 8)
+      fb.reverseAdd(v: 2.4, postion: 0)
+      fb.reverseAdd(v: 2.4, postion: 8)
+      fb.endStruct()
     }
-    let vector = fb.createVector(ofOffsets: offsets)
+    let vector = fb.endVectorOfStructs(count: 5)
     let start = fb.startTable(with: 1)
     fb.add(offset: vector, at: 4)
-    let root = Offset<UOffset>(offset: fb.endTable(at: start))
-    fb.finish(offset: root)
+    offsets.append(Offset<UOffset>(offset: fb.endTable(at: start)))
+  }
+  let vector = fb.createVector(ofOffsets: offsets)
+  let start = fb.startTable(with: 1)
+  fb.add(offset: vector, at: 4)
+  let root = Offset<UOffset>(offset: fb.endTable(at: start))
+  fb.finish(offset: root)
 }
 
 func benchmark(numberOfRuns runs: Int) {
-    var benchmarks: [Benchmark] = []
-    let str = (0...99).map { _ -> String in return "x" }.joined()
-    benchmarks.append(run(name: "500_000", runs: runs, action: benchmarkFiveHundredAdds))
-    benchmarks.append(run(name: "10 str", runs: runs, action: create10Strings))
-    let hundredStr = run(name: "100 str", runs: runs) {
-        create100Strings(str: str)
-    }
-    benchmarks.append(run(name: "3M strc", runs: 1, action: benchmarkThreeMillionStructs))
-    benchmarks.append(hundredStr)
-    print(createDocument(Benchmarks: benchmarks))
+  var benchmarks: [Benchmark] = []
+  let str = (0...99).map { _ -> String in "x" }.joined()
+  benchmarks.append(run(name: "500_000", runs: runs, action: benchmarkFiveHundredAdds))
+  benchmarks.append(run(name: "10 str", runs: runs, action: create10Strings))
+  let hundredStr = run(name: "100 str", runs: runs) {
+    create100Strings(str: str)
+  }
+  benchmarks.append(run(name: "3M strc", runs: 1, action: benchmarkThreeMillionStructs))
+  benchmarks.append(hundredStr)
+  print(createDocument(Benchmarks: benchmarks))
 }
 
 benchmark(numberOfRuns: 20)