We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5edf709 commit c7c454fCopy full SHA for c7c454f
influxdb-client/WriteBuilder.m
@@ -47,23 +47,14 @@
47
48
% Build line protocol
49
function lines = build(obj)
50
- lines = '';
51
if isempty(obj.Items)
52
warning('this writer is empty');
53
- elseif isscalar(obj.Items)
54
- item = obj.Items{1};
55
- lines = item.toLine(obj.Precision);
+ lines = '';
56
else
57
- for i = 1:length(obj.Items)
58
- item = obj.Items{i};
59
- line = item.toLine(obj.Precision);
60
- if ~isempty(line)
61
- lines = [lines, line, newline];
62
- end
63
64
- if ~isempty(lines)
65
- lines = lines(1:end - 1);
66
+ f = @(x) x.toLine(obj.Precision);
+ items = cellfun(f, obj.Items, 'UniformOutput', false);
+ nonempty = cellfun(@(x) ~isempty(x), items);
+ lines = strjoin(items(nonempty), newline);
67
end
68
69
0 commit comments