This is a static copy of a profile report

Home

opaque.char (Calls: 1, Time: 0.001 s)
Generated 18-May-2021 16:05:20 using performance time.
function in file /usr/local/MATLAB/R2021a/toolbox/matlab/datatypes/@opaque/char.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
docrootfunction1
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
11
if ~isjava(opaque_array)
10.000 s21.2%
21
cel = cell(opaque_array);
10.000 s17.3%
30
if isa(opaque_array,'java.lang...
10.000 s16.1%
32
return;
10.000 s15.3%
31
chr = cel{1};
10.000 s5.6%
All other lines  0.000 s24.4%
Totals  0.001 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function100
Non-code lines (comments, blank lines)42
Code lines (lines that can run)58
Code lines that did run8
Code lines that did not run50
Coverage (did run/can run)13.79 %
Function listing
time 
Calls 
 line
   1 
function chr = char(opaque_array)
   2 
%CHAR Convert a Java object to CHAR
   3 

   4 
%   Chip Nylander, June 1998
   5 
%   Copyright 1984-2017 The MathWorks, Inc.
   6 

   7 
%
   8 
% For opaque types other than those programmed here, just run the default
   9 
% builtin char function.
  10 
%
< 0.001 
      1 
  11
if ~isjava(opaque_array) 
  12 
    chr = builtin('char', opaque_array);
  13 
    return
< 0.001 
      1 
  14
end 
  15 

  16 
%
  17 
% Convert opaque array to cell array to get the items in it.
  18 
%
  19 

      1 
  20
try 
< 0.001 
      1 
  21
  cel = cell(opaque_array); 
  22 
catch exception %#ok 
  23 
  chr = '';
  24 
  return
      1 
  25
end 
  26 

  27 
%
  28 
% A java.lang.String object becomes a char array.
  29 
%
< 0.001 
      1 
  30
if isa(opaque_array,'java.lang.String') 
< 0.001 
      1 
  31
  chr = cel{1}; 
< 0.001 
      1 
  32
  return; 
  33 
end
  34 

  35 
%
  36 
% An empty Java array becomes an empty char array.
  37 
%
  38 
sz = builtin('size', cel);
  39 
psz = prod(sz);
  40 

  41 
if psz == 0
  42 
  try
  43 
    chr = reshape('',size(cel));
  44 
  catch
  45 
    chr = '';
  46 
  end
  47 
  return
  48 
end
  49 

  50 
%
  51 
% A java.lang.String array becomes a char array.
  52 
%
  53 
chr = cell(sz);
  54 

  55 
for i=1:psz
  56 
  chr{i} = '';
  57 
end
  58 

  59 
t = opaque_array(1);
  60 
c = class(t);
  61 

  62 
while contains(c,'[]')
  63 
  t = t(1);
  64 
  c = class(t);
  65 
end
  66 

  67 
if psz == 1 && ischar(t) && size(t,1) == 1
  68 
  chr = t;
  69 
  return;
  70 
end
  71 

  72 
if isa(t,'java.lang.String')
  73 
  chr = char(cel);
  74 
  return;
  75 
end
  76 

  77 
%
  78 
%
  79 
% Run toChar on each Java object in the MATLAB array.  This will error
  80 
% out if a toChar method is not available for the Java class of the object.
  81 
%
  82 
% A scalar array becomes a single char array.
  83 
%
  84 
if psz == 1
  85 
  if ~isjava(opaque_array(1))
  86 
    chr = builtin('char',opaque_array(1));
  87 
  else
  88 
    chr = toChar(opaque_array(1));
  89 
  end
  90 
else
  91 
  for i = 1:psz
  92 
    if ~isjava(cel{i})
  93 
      chr{i} = builtin('char',cel{i});
  94 
    else
  95 
      chr{i} = toChar(cel{i});
  96 
    end
  97 
  end
  98 
end
  99 

 100 
chr=char(chr);

Other subfunctions in this file are not included in this listing.