Skip to content

Commit 104f405

Browse files
committed
std.mem: Rename splitFull/tokenizeFull to splitSequence/tokenizeSequence
I think this makes the name less ambiguous and more obvious that the suffix applies to the `delimiter`.
1 parent 2129f28 commit 104f405

File tree

4 files changed

+62
-62
lines changed

4 files changed

+62
-62
lines changed

lib/std/mem.zig

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1910,7 +1910,7 @@ test "byteSwapAllFields" {
19101910
}, s);
19111911
}
19121912

1913-
/// Deprecated: use `tokenizeAny`, `tokenizeFull`, or `tokenizeScalar`
1913+
/// Deprecated: use `tokenizeAny`, `tokenizeSequence`, or `tokenizeScalar`
19141914
pub const tokenize = tokenizeAny;
19151915

19161916
/// Returns an iterator that iterates over the slices of `buffer` that are not
@@ -1923,9 +1923,9 @@ pub const tokenize = tokenizeAny;
19231923
/// If none of `delimiters` exist in buffer,
19241924
/// the iterator will return `buffer`, null, in that order.
19251925
///
1926-
/// See also: `tokenizeFull`, `tokenizeScalar`,
1927-
/// `splitFull`,`splitAny`, `splitScalar`,
1928-
/// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar`
1926+
/// See also: `tokenizeSequence`, `tokenizeScalar`,
1927+
/// `splitSequence`,`splitAny`, `splitScalar`,
1928+
/// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar`
19291929
pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) TokenIterator(T, .any) {
19301930
return .{
19311931
.index = 0,
@@ -1937,7 +1937,7 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T
19371937
/// Returns an iterator that iterates over the slices of `buffer` that are not
19381938
/// the sequence in `delimiter`.
19391939
///
1940-
/// `tokenizeFull(u8, "<>abc><def<><>ghi", "<>")` will return slices
1940+
/// `tokenizeSequence(u8, "<>abc><def<><>ghi", "<>")` will return slices
19411941
/// for "abc><def", "ghi", null, in that order.
19421942
///
19431943
/// If `buffer` is empty, the iterator will return null.
@@ -1946,9 +1946,9 @@ pub fn tokenizeAny(comptime T: type, buffer: []const T, delimiters: []const T) T
19461946
/// The delimiter length must not be zero.
19471947
///
19481948
/// See also: `tokenizeAny`, `tokenizeScalar`,
1949-
/// `splitFull`,`splitAny`, and `splitScalar`
1950-
/// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar`
1951-
pub fn tokenizeFull(comptime T: type, buffer: []const T, delimiter: []const T) TokenIterator(T, .full) {
1949+
/// `splitSequence`,`splitAny`, and `splitScalar`
1950+
/// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar`
1951+
pub fn tokenizeSequence(comptime T: type, buffer: []const T, delimiter: []const T) TokenIterator(T, .sequence) {
19521952
assert(delimiter.len != 0);
19531953
return .{
19541954
.index = 0,
@@ -1967,9 +1967,9 @@ pub fn tokenizeFull(comptime T: type, buffer: []const T, delimiter: []const T) T
19671967
/// If `delimiter` does not exist in buffer,
19681968
/// the iterator will return `buffer`, null, in that order.
19691969
///
1970-
/// See also: `tokenizeAny`, `tokenizeFull`,
1971-
/// `splitFull`,`splitAny`, and `splitScalar`
1972-
/// `splitBackwardsFull`, `splitBackwardsAny`, and `splitBackwardsScalar`
1970+
/// See also: `tokenizeAny`, `tokenizeSequence`,
1971+
/// `splitSequence`,`splitAny`, and `splitScalar`
1972+
/// `splitBackwardsSequence`, `splitBackwardsAny`, and `splitBackwardsScalar`
19731973
pub fn tokenizeScalar(comptime T: type, buffer: []const T, delimiter: T) TokenIterator(T, .scalar) {
19741974
return .{
19751975
.index = 0,
@@ -2019,7 +2019,7 @@ test "tokenizeScalar" {
20192019
try testing.expect(it16.next() == null);
20202020
}
20212021

2022-
test "tokenizeAny (multibyte)" {
2022+
test "tokenizeAny" {
20232023
var it = tokenizeAny(u8, "a|b,c/d e", " /,|");
20242024
try testing.expect(eql(u8, it.next().?, "a"));
20252025
try testing.expect(eql(u8, it.peek().?, "b"));
@@ -2047,8 +2047,8 @@ test "tokenizeAny (multibyte)" {
20472047
try testing.expect(it16.next() == null);
20482048
}
20492049

2050-
test "tokenizeFull" {
2051-
var it = tokenizeFull(u8, "a<>b<><>c><>d><", "<>");
2050+
test "tokenizeSequence" {
2051+
var it = tokenizeSequence(u8, "a<>b<><>c><>d><", "<>");
20522052
try testing.expectEqualStrings("a", it.next().?);
20532053
try testing.expectEqualStrings("b", it.peek().?);
20542054
try testing.expectEqualStrings("b", it.next().?);
@@ -2057,7 +2057,7 @@ test "tokenizeFull" {
20572057
try testing.expect(it.next() == null);
20582058
try testing.expect(it.peek() == null);
20592059

2060-
var it16 = tokenizeFull(
2060+
var it16 = tokenizeSequence(
20612061
u16,
20622062
std.unicode.utf8ToUtf16LeStringLiteral("a<>b<><>c><>d><"),
20632063
std.unicode.utf8ToUtf16LeStringLiteral("<>"),
@@ -2084,7 +2084,7 @@ test "tokenize (reset)" {
20842084
try testing.expect(it.next() == null);
20852085
}
20862086
{
2087-
var it = tokenizeFull(u8, "<><>abc<>def<><>ghi<>", "<>");
2087+
var it = tokenizeSequence(u8, "<><>abc<>def<><>ghi<>", "<>");
20882088
try testing.expect(eql(u8, it.next().?, "abc"));
20892089
try testing.expect(eql(u8, it.next().?, "def"));
20902090
try testing.expect(eql(u8, it.next().?, "ghi"));
@@ -2111,23 +2111,23 @@ test "tokenize (reset)" {
21112111
}
21122112
}
21132113

2114-
/// Deprecated: use `splitFull`, `splitAny`, or `splitScalar`
2115-
pub const split = splitFull;
2114+
/// Deprecated: use `splitSequence`, `splitAny`, or `splitScalar`
2115+
pub const split = splitSequence;
21162116

21172117
/// Returns an iterator that iterates over the slices of `buffer` that
21182118
/// are separated by the byte sequence in `delimiter`.
21192119
///
2120-
/// `splitFull(u8, "abc||def||||ghi", "||")` will return slices
2120+
/// `splitSequence(u8, "abc||def||||ghi", "||")` will return slices
21212121
/// for "abc", "def", "", "ghi", null, in that order.
21222122
///
21232123
/// If `delimiter` does not exist in buffer,
21242124
/// the iterator will return `buffer`, null, in that order.
21252125
/// The delimiter length must not be zero.
21262126
///
2127-
/// See also: `splitAny`, `splitScalar`, `splitBackwardsFull`,
2127+
/// See also: `splitAny`, `splitScalar`, `splitBackwardsSequence`,
21282128
/// `splitBackwardsAny`,`splitBackwardsScalar`,
2129-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2130-
pub fn splitFull(comptime T: type, buffer: []const T, delimiter: []const T) SplitIterator(T, .full) {
2129+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
2130+
pub fn splitSequence(comptime T: type, buffer: []const T, delimiter: []const T) SplitIterator(T, .sequence) {
21312131
assert(delimiter.len != 0);
21322132
return .{
21332133
.index = 0,
@@ -2145,9 +2145,9 @@ pub fn splitFull(comptime T: type, buffer: []const T, delimiter: []const T) Spli
21452145
/// If none of `delimiters` exist in buffer,
21462146
/// the iterator will return `buffer`, null, in that order.
21472147
///
2148-
/// See also: `splitFull`, `splitScalar`, `splitBackwardsFull`,
2148+
/// See also: `splitSequence`, `splitScalar`, `splitBackwardsSequence`,
21492149
/// `splitBackwardsAny`,`splitBackwardsScalar`,
2150-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2150+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
21512151
pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitIterator(T, .any) {
21522152
return .{
21532153
.index = 0,
@@ -2165,9 +2165,9 @@ pub fn splitAny(comptime T: type, buffer: []const T, delimiters: []const T) Spli
21652165
/// If `delimiter` does not exist in buffer,
21662166
/// the iterator will return `buffer`, null, in that order.
21672167
///
2168-
/// See also: `splitFull`, `splitAny`, `splitBackwardsFull`,
2168+
/// See also: `splitSequence`, `splitAny`, `splitBackwardsSequence`,
21692169
/// `splitBackwardsAny`,`splitBackwardsScalar`,
2170-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2170+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
21712171
pub fn splitScalar(comptime T: type, buffer: []const T, delimiter: T) SplitIterator(T, .scalar) {
21722172
return .{
21732173
.index = 0,
@@ -2215,8 +2215,8 @@ test "splitScalar" {
22152215
try testing.expect(it16.next() == null);
22162216
}
22172217

2218-
test "splitFull (multibyte)" {
2219-
var it = splitFull(u8, "a, b ,, c, d, e", ", ");
2218+
test "splitSequence" {
2219+
var it = splitSequence(u8, "a, b ,, c, d, e", ", ");
22202220
try testing.expectEqualSlices(u8, it.first(), "a");
22212221
try testing.expectEqualSlices(u8, it.rest(), "b ,, c, d, e");
22222222
try testing.expectEqualSlices(u8, it.next().?, "b ,");
@@ -2225,7 +2225,7 @@ test "splitFull (multibyte)" {
22252225
try testing.expectEqualSlices(u8, it.next().?, "e");
22262226
try testing.expect(it.next() == null);
22272227

2228-
var it16 = splitFull(
2228+
var it16 = splitSequence(
22292229
u16,
22302230
std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"),
22312231
std.unicode.utf8ToUtf16LeStringLiteral(", "),
@@ -2269,7 +2269,7 @@ test "splitAny" {
22692269

22702270
test "split (reset)" {
22712271
{
2272-
var it = splitFull(u8, "abc def ghi", " ");
2272+
var it = splitSequence(u8, "abc def ghi", " ");
22732273
try testing.expect(eql(u8, it.first(), "abc"));
22742274
try testing.expect(eql(u8, it.next().?, "def"));
22752275
try testing.expect(eql(u8, it.next().?, "ghi"));
@@ -2309,23 +2309,23 @@ test "split (reset)" {
23092309
}
23102310
}
23112311

2312-
/// Deprecated: use `splitBackwardsFull`, `splitBackwardsAny`, or `splitBackwardsScalar`
2313-
pub const splitBackwards = splitBackwardsFull;
2312+
/// Deprecated: use `splitBackwardsSequence`, `splitBackwardsAny`, or `splitBackwardsScalar`
2313+
pub const splitBackwards = splitBackwardsSequence;
23142314

23152315
/// Returns an iterator that iterates backwards over the slices of `buffer` that
23162316
/// are separated by the sequence in `delimiter`.
23172317
///
2318-
/// `splitBackwardsFull(u8, "abc||def||||ghi", "||")` will return slices
2318+
/// `splitBackwardsSequence(u8, "abc||def||||ghi", "||")` will return slices
23192319
/// for "ghi", "", "def", "abc", null, in that order.
23202320
///
23212321
/// If `delimiter` does not exist in buffer,
23222322
/// the iterator will return `buffer`, null, in that order.
23232323
/// The delimiter length must not be zero.
23242324
///
23252325
/// See also: `splitBackwardsAny`, `splitBackwardsScalar`,
2326-
/// `splitFull`, `splitAny`,`splitScalar`,
2327-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2328-
pub fn splitBackwardsFull(comptime T: type, buffer: []const T, delimiter: []const T) SplitBackwardsIterator(T, .full) {
2326+
/// `splitSequence`, `splitAny`,`splitScalar`,
2327+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
2328+
pub fn splitBackwardsSequence(comptime T: type, buffer: []const T, delimiter: []const T) SplitBackwardsIterator(T, .sequence) {
23292329
assert(delimiter.len != 0);
23302330
return .{
23312331
.index = buffer.len,
@@ -2343,9 +2343,9 @@ pub fn splitBackwardsFull(comptime T: type, buffer: []const T, delimiter: []cons
23432343
/// If none of `delimiters` exist in buffer,
23442344
/// the iterator will return `buffer`, null, in that order.
23452345
///
2346-
/// See also: `splitBackwardsFull`, `splitBackwardsScalar`,
2347-
/// `splitFull`, `splitAny`,`splitScalar`,
2348-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2346+
/// See also: `splitBackwardsSequence`, `splitBackwardsScalar`,
2347+
/// `splitSequence`, `splitAny`,`splitScalar`,
2348+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
23492349
pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []const T) SplitBackwardsIterator(T, .any) {
23502350
return .{
23512351
.index = buffer.len,
@@ -2363,9 +2363,9 @@ pub fn splitBackwardsAny(comptime T: type, buffer: []const T, delimiters: []cons
23632363
/// If `delimiter` does not exist in buffer,
23642364
/// the iterator will return `buffer`, null, in that order.
23652365
///
2366-
/// See also: `splitBackwardsFull`, `splitBackwardsAny`,
2367-
/// `splitFull`, `splitAny`,`splitScalar`,
2368-
/// `tokenizeAny`, `tokenizeFull`, and `tokenizeScalar`.
2366+
/// See also: `splitBackwardsSequence`, `splitBackwardsAny`,
2367+
/// `splitSequence`, `splitAny`,`splitScalar`,
2368+
/// `tokenizeAny`, `tokenizeSequence`, and `tokenizeScalar`.
23692369
pub fn splitBackwardsScalar(comptime T: type, buffer: []const T, delimiter: T) SplitBackwardsIterator(T, .scalar) {
23702370
return .{
23712371
.index = buffer.len,
@@ -2413,8 +2413,8 @@ test "splitBackwardsScalar" {
24132413
try testing.expect(it16.next() == null);
24142414
}
24152415

2416-
test "splitBackwardsFull (multibyte)" {
2417-
var it = splitBackwardsFull(u8, "a, b ,, c, d, e", ", ");
2416+
test "splitBackwardsSequence" {
2417+
var it = splitBackwardsSequence(u8, "a, b ,, c, d, e", ", ");
24182418
try testing.expectEqualSlices(u8, it.rest(), "a, b ,, c, d, e");
24192419
try testing.expectEqualSlices(u8, it.first(), "e");
24202420

@@ -2433,7 +2433,7 @@ test "splitBackwardsFull (multibyte)" {
24332433
try testing.expectEqualSlices(u8, it.rest(), "");
24342434
try testing.expect(it.next() == null);
24352435

2436-
var it16 = splitBackwardsFull(
2436+
var it16 = splitBackwardsSequence(
24372437
u16,
24382438
std.unicode.utf8ToUtf16LeStringLiteral("a, b ,, c, d, e"),
24392439
std.unicode.utf8ToUtf16LeStringLiteral(", "),
@@ -2485,7 +2485,7 @@ test "splitBackwardsAny" {
24852485

24862486
test "splitBackwards (reset)" {
24872487
{
2488-
var it = splitBackwardsFull(u8, "abc def ghi", " ");
2488+
var it = splitBackwardsSequence(u8, "abc def ghi", " ");
24892489
try testing.expect(eql(u8, it.first(), "ghi"));
24902490
try testing.expect(eql(u8, it.next().?, "def"));
24912491
try testing.expect(eql(u8, it.next().?, "abc"));
@@ -2693,13 +2693,13 @@ test "endsWith" {
26932693
try testing.expect(!endsWith(u8, "Bob", "Bo"));
26942694
}
26952695

2696-
pub const DelimiterType = enum { full, any, scalar };
2696+
pub const DelimiterType = enum { sequence, any, scalar };
26972697

26982698
pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) type {
26992699
return struct {
27002700
buffer: []const T,
27012701
delimiter: switch (delimiter_type) {
2702-
.full, .any => []const T,
2702+
.sequence, .any => []const T,
27032703
.scalar => T,
27042704
},
27052705
index: usize,
@@ -2719,7 +2719,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
27192719
pub fn peek(self: *Self) ?[]const T {
27202720
// move to beginning of token
27212721
while (self.index < self.buffer.len and self.isDelimiter(self.index)) : (self.index += switch (delimiter_type) {
2722-
.full => self.delimiter.len,
2722+
.sequence => self.delimiter.len,
27232723
.any, .scalar => 1,
27242724
}) {}
27252725
const start = self.index;
@@ -2739,7 +2739,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
27392739
// move to beginning of token
27402740
var index: usize = self.index;
27412741
while (index < self.buffer.len and self.isDelimiter(index)) : (index += switch (delimiter_type) {
2742-
.full => self.delimiter.len,
2742+
.sequence => self.delimiter.len,
27432743
.any, .scalar => 1,
27442744
}) {}
27452745
return self.buffer[index..];
@@ -2752,7 +2752,7 @@ pub fn TokenIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
27522752

27532753
fn isDelimiter(self: Self, index: usize) bool {
27542754
switch (delimiter_type) {
2755-
.full => return startsWith(T, self.buffer[index..], self.delimiter),
2755+
.sequence => return startsWith(T, self.buffer[index..], self.delimiter),
27562756
.any => {
27572757
const item = self.buffer[index];
27582758
for (self.delimiter) |delimiter_item| {
@@ -2773,7 +2773,7 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
27732773
buffer: []const T,
27742774
index: ?usize,
27752775
delimiter: switch (delimiter_type) {
2776-
.full, .any => []const T,
2776+
.sequence, .any => []const T,
27772777
.scalar => T,
27782778
},
27792779

@@ -2790,12 +2790,12 @@ pub fn SplitIterator(comptime T: type, comptime delimiter_type: DelimiterType) t
27902790
pub fn next(self: *Self) ?[]const T {
27912791
const start = self.index orelse return null;
27922792
const end = if (switch (delimiter_type) {
2793-
.full => indexOfPos(T, self.buffer, start, self.delimiter),
2793+
.sequence => indexOfPos(T, self.buffer, start, self.delimiter),
27942794
.any => indexOfAnyPos(T, self.buffer, start, self.delimiter),
27952795
.scalar => indexOfScalarPos(T, self.buffer, start, self.delimiter),
27962796
}) |delim_start| blk: {
27972797
self.index = delim_start + switch (delimiter_type) {
2798-
.full => self.delimiter.len,
2798+
.sequence => self.delimiter.len,
27992799
.any, .scalar => 1,
28002800
};
28012801
break :blk delim_start;
@@ -2825,7 +2825,7 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit
28252825
buffer: []const T,
28262826
index: ?usize,
28272827
delimiter: switch (delimiter_type) {
2828-
.full, .any => []const T,
2828+
.sequence, .any => []const T,
28292829
.scalar => T,
28302830
},
28312831

@@ -2842,13 +2842,13 @@ pub fn SplitBackwardsIterator(comptime T: type, comptime delimiter_type: Delimit
28422842
pub fn next(self: *Self) ?[]const T {
28432843
const end = self.index orelse return null;
28442844
const start = if (switch (delimiter_type) {
2845-
.full => lastIndexOf(T, self.buffer[0..end], self.delimiter),
2845+
.sequence => lastIndexOf(T, self.buffer[0..end], self.delimiter),
28462846
.any => lastIndexOfAny(T, self.buffer[0..end], self.delimiter),
28472847
.scalar => lastIndexOfScalar(T, self.buffer[0..end], self.delimiter),
28482848
}) |delim_start| blk: {
28492849
self.index = delim_start;
28502850
break :blk delim_start + switch (delimiter_type) {
2851-
.full => self.delimiter.len,
2851+
.sequence => self.delimiter.len,
28522852
.any, .scalar => 1,
28532853
};
28542854
} else blk: {

lib/std/zig/CrossTarget.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -706,7 +706,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
706706
.linux,
707707
.dragonfly,
708708
=> {
709-
var range_it = mem.splitFull(u8, version_text, "...");
709+
var range_it = mem.splitSequence(u8, version_text, "...");
710710

711711
const min_text = range_it.next().?;
712712
const min_ver = SemVer.parse(min_text) catch |err| switch (err) {
@@ -726,7 +726,7 @@ fn parseOs(result: *CrossTarget, diags: *ParseOptions.Diagnostics, text: []const
726726
},
727727

728728
.windows => {
729-
var range_it = mem.splitFull(u8, version_text, "...");
729+
var range_it = mem.splitSequence(u8, version_text, "...");
730730

731731
const min_text = range_it.first();
732732
const min_ver = std.meta.stringToEnum(Target.Os.WindowsVersion, min_text) orelse

src/Compilation.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5016,14 +5016,14 @@ fn parseLldStderr(comp: *Compilation, comptime prefix: []const u8, stderr: []con
50165016
defer context_lines.deinit();
50175017

50185018
var current_err: ?*LldError = null;
5019-
var lines = mem.splitFull(u8, stderr, std.cstr.line_sep);
5019+
var lines = mem.splitSequence(u8, stderr, std.cstr.line_sep);
50205020
while (lines.next()) |line| {
50215021
if (mem.startsWith(u8, line, prefix ++ ":")) {
50225022
if (current_err) |err| {
50235023
err.context_lines = try context_lines.toOwnedSlice();
50245024
}
50255025

5026-
var split = std.mem.splitFull(u8, line, "error: ");
5026+
var split = std.mem.splitSequence(u8, line, "error: ");
50275027
_ = split.first();
50285028

50295029
const duped_msg = try std.fmt.allocPrint(comp.gpa, "{s}: {s}", .{ prefix, split.rest() });

tools/update_crc_catalog.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub fn main() anyerror!void {
7878
var residue: []const u8 = undefined;
7979
var name: []const u8 = undefined;
8080

81-
var it = mem.splitFull(u8, line, " ");
81+
var it = mem.splitSequence(u8, line, " ");
8282
while (it.next()) |property| {
8383
const i = mem.indexOf(u8, property, "=").?;
8484
const key = property[0..i];

0 commit comments

Comments
 (0)