Skip to content

Commit b8dba59

Browse files
authored
Import swift algorithms (ChartsOrg#4497)
* Use Algorithms implementation of binary search * Use `indexed()` where appropriate * Update Package.swift to include SwiftAlgorithms * Use lazy implementation of `prefix(while:)` For better performance * Revert "Use lazy implementation of `prefix(while:)`" This reverts commit 69a303f.
1 parent 857db24 commit b8dba59

File tree

9 files changed

+174
-151
lines changed

9 files changed

+174
-151
lines changed

Charts.xcodeproj/project.pbxproj

+66-11
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
archiveVersion = 1;
44
classes = {
55
};
6-
objectVersion = 46;
6+
objectVersion = 52;
77
objects = {
88

99
/* Begin PBXBuildFile section */
@@ -29,6 +29,7 @@
2929
219192CA6B4895319AB49DCA /* BarLineScatterCandleBubbleRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5B1C588E9DF6FFD56D7ADF8E /* BarLineScatterCandleBubbleRenderer.swift */; };
3030
221CA2922588FCBC00C2DD1E /* Sequence+KeyPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = 221CA2912588FCBC00C2DD1E /* Sequence+KeyPath.swift */; };
3131
2243BBFD1FF156EC00B49D0B /* EquatableTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2243BBFB1FF156D000B49D0B /* EquatableTests.swift */; };
32+
228D56232554F27A00BEE75E /* Algorithms in Frameworks */ = {isa = PBXBuildFile; productRef = 228D56222554F27A00BEE75E /* Algorithms */; };
3233
23649EFC635A76022F07FFA6 /* PieChartDataEntry.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD02157CF8CEE1189BF681DA /* PieChartDataEntry.swift */; };
3334
23FA50B2730D8C7ACA091C4F /* BarChartRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 75F279974FE650E57A061B09 /* BarChartRenderer.swift */; };
3435
24151B0729D77251A8494D70 /* LineRadarRenderer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 105FFC9D3773A9C7A60A897F /* LineRadarRenderer.swift */; };
@@ -344,6 +345,7 @@
344345
isa = PBXFrameworksBuildPhase;
345346
buildActionMask = 2147483647;
346347
files = (
348+
228D56232554F27A00BEE75E /* Algorithms in Frameworks */,
347349
);
348350
runOnlyForDeploymentPostprocessing = 0;
349351
};
@@ -748,6 +750,9 @@
748750
dependencies = (
749751
);
750752
name = Charts;
753+
packageProductDependencies = (
754+
228D56222554F27A00BEE75E /* Algorithms */,
755+
);
751756
productName = Charts;
752757
productReference = 65AD9E95D9ED4DC0BD73A743 /* Charts.framework */;
753758
productType = "com.apple.product-type.framework";
@@ -798,6 +803,9 @@
798803
Base,
799804
);
800805
mainGroup = 865A1CF149F52850CAB7F177;
806+
packageReferences = (
807+
228D56212554F27A00BEE75E /* XCRemoteSwiftPackageReference "swift-algorithms" */,
808+
);
801809
productRefGroup = AB2D554102718F209377399E /* Products */;
802810
projectDirPath = "";
803811
projectRoot = "";
@@ -1050,7 +1058,11 @@
10501058
INFOPLIST_FILE = "Source/Supporting Files/Info.plist";
10511059
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
10521060
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
1053-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
1061+
LD_RUNPATH_SEARCH_PATHS = (
1062+
"$(inherited)",
1063+
"@executable_path/../Frameworks",
1064+
"@loader_path/Frameworks",
1065+
);
10541066
MACOSX_DEPLOYMENT_TARGET = 10.11;
10551067
MARKETING_VERSION = 4.0.0;
10561068
MTL_ENABLE_DEBUG_INFO = YES;
@@ -1085,8 +1097,16 @@
10851097
GCC_NO_COMMON_BLOCKS = YES;
10861098
INFOPLIST_FILE = "Tests/Supporting Files/Info.plist";
10871099
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
1088-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1089-
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
1100+
LD_RUNPATH_SEARCH_PATHS = (
1101+
"$(inherited)",
1102+
"@executable_path/Frameworks",
1103+
"@loader_path/Frameworks",
1104+
);
1105+
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
1106+
"$(inherited)",
1107+
"@executable_path/../Frameworks",
1108+
"@loader_path/../Frameworks",
1109+
);
10901110
MTL_ENABLE_DEBUG_INFO = YES;
10911111
PRODUCT_BUNDLE_IDENTIFIER = com.dcg.ChartsTests;
10921112
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -1145,7 +1165,8 @@
11451165
GCC_WARN_UNUSED_FUNCTION = YES;
11461166
GCC_WARN_UNUSED_VARIABLE = YES;
11471167
SDKROOT = macosx;
1148-
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1168+
SWIFT_COMPILATION_MODE = wholemodule;
1169+
SWIFT_OPTIMIZATION_LEVEL = "-O";
11491170
SWIFT_VERSION = 5.0;
11501171
TARGETED_DEVICE_FAMILY = "1,2,3,4";
11511172
VALIDATE_PRODUCT = YES;
@@ -1206,7 +1227,8 @@
12061227
GCC_WARN_UNUSED_VARIABLE = YES;
12071228
ONLY_ACTIVE_ARCH = YES;
12081229
SDKROOT = macosx;
1209-
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1230+
SWIFT_COMPILATION_MODE = wholemodule;
1231+
SWIFT_OPTIMIZATION_LEVEL = "-O";
12101232
SWIFT_VERSION = 5.0;
12111233
TARGETED_DEVICE_FAMILY = "1,2,3,4";
12121234
};
@@ -1229,7 +1251,11 @@
12291251
INFOPLIST_FILE = "Source/Supporting Files/Info.plist";
12301252
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
12311253
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
1232-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks";
1254+
LD_RUNPATH_SEARCH_PATHS = (
1255+
"$(inherited)",
1256+
"@executable_path/../Frameworks",
1257+
"@loader_path/Frameworks",
1258+
);
12331259
MACOSX_DEPLOYMENT_TARGET = 10.11;
12341260
MARKETING_VERSION = 4.0.0;
12351261
MTL_ENABLE_DEBUG_INFO = NO;
@@ -1238,7 +1264,8 @@
12381264
SDKROOT = macosx;
12391265
SKIP_INSTALL = YES;
12401266
SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator";
1241-
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1267+
SWIFT_COMPILATION_MODE = wholemodule;
1268+
SWIFT_OPTIMIZATION_LEVEL = "-O";
12421269
SWIFT_VERSION = 5.0;
12431270
TVOS_DEPLOYMENT_TARGET = 9.0;
12441271
VERSIONING_SYSTEM = "apple-generic";
@@ -1263,14 +1290,23 @@
12631290
GCC_NO_COMMON_BLOCKS = YES;
12641291
INFOPLIST_FILE = "Tests/Supporting Files/Info.plist";
12651292
IPHONEOS_DEPLOYMENT_TARGET = 9.0;
1266-
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
1267-
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks";
1293+
LD_RUNPATH_SEARCH_PATHS = (
1294+
"$(inherited)",
1295+
"@executable_path/Frameworks",
1296+
"@loader_path/Frameworks",
1297+
);
1298+
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = (
1299+
"$(inherited)",
1300+
"@executable_path/../Frameworks",
1301+
"@loader_path/../Frameworks",
1302+
);
12681303
MTL_ENABLE_DEBUG_INFO = NO;
12691304
PRODUCT_BUNDLE_IDENTIFIER = com.dcg.ChartsTests;
12701305
PRODUCT_NAME = "$(TARGET_NAME)";
12711306
SDKROOT = macosx;
12721307
SUPPORTED_PLATFORMS = "iphoneos iphonesimulator appletvos appletvsimulator";
1273-
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
1308+
SWIFT_COMPILATION_MODE = wholemodule;
1309+
SWIFT_OPTIMIZATION_LEVEL = "-O";
12741310
SWIFT_VERSION = 5.0;
12751311
TVOS_DEPLOYMENT_TARGET = 9.0;
12761312
};
@@ -1307,6 +1343,25 @@
13071343
defaultConfigurationName = Release;
13081344
};
13091345
/* End XCConfigurationList section */
1346+
1347+
/* Begin XCRemoteSwiftPackageReference section */
1348+
228D56212554F27A00BEE75E /* XCRemoteSwiftPackageReference "swift-algorithms" */ = {
1349+
isa = XCRemoteSwiftPackageReference;
1350+
repositoryURL = "https://github.com/apple/swift-algorithms";
1351+
requirement = {
1352+
kind = upToNextMajorVersion;
1353+
minimumVersion = 0.0.2;
1354+
};
1355+
};
1356+
/* End XCRemoteSwiftPackageReference section */
1357+
1358+
/* Begin XCSwiftPackageProductDependency section */
1359+
228D56222554F27A00BEE75E /* Algorithms */ = {
1360+
isa = XCSwiftPackageProductDependency;
1361+
package = 228D56212554F27A00BEE75E /* XCRemoteSwiftPackageReference "swift-algorithms" */;
1362+
productName = Algorithms;
1363+
};
1364+
/* End XCSwiftPackageProductDependency section */
13101365
};
13111366
rootObject = 193FC8DF32D250560C5F5D77 /* Project object */;
13121367
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"object": {
3+
"pins": [
4+
{
5+
"package": "swift-algorithms",
6+
"repositoryURL": "https://github.com/apple/swift-algorithms",
7+
"state": {
8+
"branch": null,
9+
"revision": "bb3bafeca0e164ece3403a9de646b7d38c07dd49",
10+
"version": "0.0.2"
11+
}
12+
},
13+
{
14+
"package": "swift-numerics",
15+
"repositoryURL": "https://github.com/apple/swift-numerics",
16+
"state": {
17+
"branch": null,
18+
"revision": "6b24333510e9044cf4716a07bed65eeed6bc6393",
19+
"version": "0.0.8"
20+
}
21+
}
22+
]
23+
},
24+
"version": 1
25+
}

Package.resolved

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"object": {
3+
"pins": [
4+
{
5+
"package": "swift-algorithms",
6+
"repositoryURL": "https://github.com/apple/swift-algorithms",
7+
"state": {
8+
"branch": null,
9+
"revision": "bb3bafeca0e164ece3403a9de646b7d38c07dd49",
10+
"version": "0.0.2"
11+
}
12+
},
13+
{
14+
"package": "swift-numerics",
15+
"repositoryURL": "https://github.com/apple/swift-numerics",
16+
"state": {
17+
"branch": null,
18+
"revision": "6b24333510e9044cf4716a07bed65eeed6bc6393",
19+
"version": "0.0.8"
20+
}
21+
}
22+
]
23+
},
24+
"version": 1
25+
}

Package.swift

+7-1
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,14 @@ let package = Package(
1818
type: .dynamic,
1919
targets: ["Charts"])
2020
],
21+
dependencies: [
22+
.package(url: "https://github.com/apple/swift-algorithms", from: "0.0.1")
23+
],
2124
targets: [
22-
.target(name: "Charts")
25+
.target(
26+
name: "Charts",
27+
dependencies: [.product(name: "Algorithms", package: "swift-algorithms")]
28+
)
2329
],
2430
swiftLanguageVersions: [.v5]
2531
)

0 commit comments

Comments
 (0)