Mercurial > repos > public > sbplib
comparison SolutionFile.m @ 35:61367018c46f
Stoped using matFile object in SolutionFile. Changed to load for performance.
author | Jonatan Werpers <jonatan@werpers.com> |
---|---|
date | Tue, 06 Oct 2015 09:48:46 +0200 |
parents | ddfb98209aa2 |
children | dd4db0c97a02 |
comparison
equal
deleted
inserted
replaced
34:2b4f1d3e5630 | 35:61367018c46f |
---|---|
18 | 18 |
19 if is_new_file | 19 if is_new_file |
20 obj.matfile.keys = {}; | 20 obj.matfile.keys = {}; |
21 obj.matfile.entries = {}; | 21 obj.matfile.entries = {}; |
22 else | 22 else |
23 matObj = matfile(filename,'Writable',true); | 23 loadStruct = load(filename); |
24 obj.matfile.keys = matObj.keys; | 24 obj.matfile.keys = loadStruct.keys; |
25 obj.matfile.entries = matObj.entries; | 25 obj.matfile.entries = loadStruct.entries; |
26 | |
27 % matObj = matfile(filename,'Writable',true); | |
28 % obj.matfile.keys = matObj.keys; | |
29 % obj.matfile.entries = matObj.entries; | |
26 end | 30 end |
27 | 31 |
28 obj.keys = obj.matfile.keys; | 32 obj.keys = obj.matfile.keys; |
29 | 33 |
30 end | 34 end |
33 matObj = matfile(obj.filename,'Writable',true); | 37 matObj = matfile(obj.filename,'Writable',true); |
34 | 38 |
35 keys = obj.matfile.keys; | 39 keys = obj.matfile.keys; |
36 entries = obj.matfile.entries; | 40 entries = obj.matfile.entries; |
37 | 41 |
38 delete(obj.filename); | 42 if exist(obj.filename,'file') |
43 delete(obj.filename); | |
44 end | |
39 | 45 |
40 matObj = matfile(obj.filename,'Writable',true); | 46 matObj = matfile(obj.filename,'Writable',true); |
41 matObj.keys = keys; | 47 matObj.keys = keys; |
42 matObj.entries = entries; | 48 matObj.entries = entries; |
43 end | 49 end |
78 end | 84 end |
79 | 85 |
80 % Gets entries where key match exactly. | 86 % Gets entries where key match exactly. |
81 function e = get(obj, key) | 87 function e = get(obj, key) |
82 if ~obj.isKey(key); | 88 if ~obj.isKey(key); |
89 key | |
83 error('No such key: %s', struct2string(key)); | 90 error('No such key: %s', struct2string(key)); |
84 end | 91 end |
85 | 92 |
86 I = obj.getIndex(key); | 93 I = obj.getIndex(key); |
87 e = obj.getEntryByIndex(I); % unpack the cell array | 94 e = obj.getEntryByIndex(I); % unpack the cell array |