Skip to content

Commit

Permalink
speed up string encoding and decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
fangq committed Apr 17, 2023
1 parent cb43ed1 commit 3c32aff
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion decodevarname.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
end

if(isunpack)
if(isempty(regexp(name,'0x([0-9a-fA-F]+)_','once')))
if(isempty(strfind(name, '0x')) || isempty(regexp(name,'0x([0-9a-fA-F]+)_','once')))
return
end
if(exist('native2unicode','builtin'))
Expand Down
2 changes: 1 addition & 1 deletion loadjson.m
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@
catch
end
end
if(~ischar(str))
if(~ischar(str) || isempty(find(str=='\', 1)))
return;
end
escapechars={'\\','\"','\/','\a','\b','\f','\n','\r','\t','\v'};
Expand Down
2 changes: 1 addition & 1 deletion savejson.m
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@
end
end
for e=1:len
if(strcmp('_ArrayZipData_',decodevarname(name,varargin{1}.unpackhex))==0)
if(strcmp('_ArrayZipData_',decodevarname(name,varargin{1}.unpackhex))==0 && ~isempty(find(item(e,:)=='\', 1)))
val=escapejsonstring(item(e,:),varargin{:});
else
val=item(e,:);
Expand Down

0 comments on commit 3c32aff

Please sign in to comment.