taskGNU Octave - Tasks: task #15469, Eliminate or reduce use of...


You are not allowed to post comments on this tracker with your current authentication level.

task #15469: Eliminate or reduce use of "mutable" keyword in C++

Submitter:  Rik <rik5>
Submitted:  Mon 18 Nov 2019 11:31:51 PM UTC
Should Start On:  Mon 18 Nov 2019 08:00:00 AM UTC Should be Finished on:  Mon 18 Nov 2019 08:00:00 AM UTC
Category:  Wish Priority:  5 - Normal
Status:  In Progress Privacy:  Public
Assigned to:  None Originator Name: 
Open/Closed:  Open Fixed Release:  None
Planned Release:  None

Mon 18 Nov 2019 11:31:51 PM UTC, original submission:  

The "mutable" keyword is often used as a hack, when really the code should be re-thought out to eliminate the need to change a member of a const object.

Instances of mutable found in libinterp:

corefcn/graphics.in.h:3185:      mutable string_property __gl_extensions__ hr , ""
corefcn/graphics.in.h:3186:      mutable string_property __gl_renderer__ hr , ""
corefcn/graphics.in.h:3187:      mutable string_property __gl_vendor__ hr , ""
corefcn/graphics.in.h:3188:      mutable string_property __gl_version__ hr , ""
corefcn/load-path.h:515:    mutable package_map_type package_map;
corefcn/load-path.h:517:    mutable package_info top_level_package;
corefcn/load-path.h:519:    mutable dir_info_list_type dir_info_list;
corefcn/load-path.h:521:    mutable std::set<std::string> init_dirs;
corefcn/mxarray.in.h:105:#define DO_MUTABLE_METHOD(RET_T, METHOD_CALL)   \
corefcn/mxarray.in.h:116:#define DO_VOID_MUTABLE_METHOD(METHOD_CALL)     \
corefcn/mxarray.in.h:431:  void set_m (mwSize m) { DO_VOID_MUTABLE_METHOD (set_m (m)); }
corefcn/mxarray.in.h:433:  void set_n (mwSize n) { DO_VOID_MUTABLE_METHOD (set_n (n)); }
corefcn/mxarray.in.h:436:  { DO_MUTABLE_METHOD (int, set_dimensions (dims_arg, ndims_arg)); }
corefcn/mxarray.in.h:460:  { DO_VOID_MUTABLE_METHOD (set_class_name (name_arg)); }
corefcn/mxarray.in.h:463:  { DO_MUTABLE_METHOD (mxArray *, get_cell (idx)); }
corefcn/mxarray.in.h:466:  { DO_VOID_MUTABLE_METHOD (set_cell (idx, val)); }
corefcn/mxarray.in.h:470:  void * get_data (void) const { DO_MUTABLE_METHOD (void *, get_data ()); }
corefcn/mxarray.in.h:473:  { DO_MUTABLE_METHOD (void *, get_imag_data ()); }
corefcn/mxarray.in.h:475:  void set_data (void *pr) { DO_VOID_MUTABLE_METHOD (set_data (pr)); }
corefcn/mxarray.in.h:477:  void set_imag_data (void *pi) { DO_VOID_MUTABLE_METHOD (set_imag_data (pi)); }
corefcn/mxarray.in.h:479:  mwIndex * get_ir (void) const { DO_MUTABLE_METHOD (mwIndex *, get_ir ()); }
corefcn/mxarray.in.h:481:  mwIndex * get_jc (void) const { DO_MUTABLE_METHOD (mwIndex *, get_jc ()); }
corefcn/mxarray.in.h:485:  void set_ir (mwIndex *ir) { DO_VOID_MUTABLE_METHOD (set_ir (ir)); }
corefcn/mxarray.in.h:487:  void set_jc (mwIndex *jc) { DO_VOID_MUTABLE_METHOD (set_jc (jc)); }
corefcn/mxarray.in.h:489:  void set_nzmax (mwSize nzmax) { DO_VOID_MUTABLE_METHOD (set_nzmax (nzmax)); }
corefcn/mxarray.in.h:491:  int add_field (const char *key) { DO_MUTABLE_METHOD (int, add_field (key)); }
corefcn/mxarray.in.h:494:  { DO_VOID_MUTABLE_METHOD (remove_field (key_num)); }
corefcn/mxarray.in.h:497:  { DO_MUTABLE_METHOD (mxArray *, get_field_by_number (index, key_num)); }
corefcn/mxarray.in.h:500:  { DO_VOID_MUTABLE_METHOD (set_field_by_number (index, key_num, val)); }
corefcn/mxarray.in.h:505:  { DO_MUTABLE_METHOD (const char*, get_field_name_by_number (key_num)); }
corefcn/mxarray.in.h:508:  { DO_MUTABLE_METHOD (int, get_field_number (key)); }
corefcn/mxarray.in.h:552:  mutable mxArray_base *rep;
corefcn/mxarray.in.h:562:#undef DO_MUTABLE_METHOD
corefcn/mxarray.in.h:563:#undef DO_VOID_MUTABLE_METHOD
corefcn/oct-stream.h:467:    mutable ostrl_map::const_iterator m_lookup_cache;
octave-value/ov-base-diag.h:247:  mutable octave_value dense_cache;
octave-value/ov-base-mat.h:210:  mutable MatrixType *typ;
octave-value/ov-base-mat.h:211:  mutable idx_vector *idx_cache;
octave-value/ov-base-sparse.h:196:  mutable MatrixType typ;
octave-value/ov-cell.h:184:  mutable std::unique_ptr<Array<std::string>> cellstr_cache;
octave-value/ov-dld-fcn.h:102:  mutable octave::sys::time t_checked;
octave-value/ov-lazy-idx.h:270:  mutable octave_value value;
octave-value/ov-mex-fcn.h:117:  mutable octave::sys::time m_time_checked;
octave-value/ov-perm.h:261:  mutable octave_value dense_cache;
octave-value/ov-range.h:332:  mutable idx_vector *idx_cache;
parse-tree/jit-typeinfo.h:434:    mutable generated_map m_generated;
corefcn/ft-text-renderer.cc:557:      mutable FT_Face face;
corefcn/mex.cc:652:  mutable bool mutate_flag;
corefcn/mex.cc:658:  mutable mxClassID id;
corefcn/mex.cc:659:  mutable char *class_name;
corefcn/mex.cc:660:  mutable mwSize ndims;
corefcn/mex.cc:661:  mutable mwSize *dims;
corefcn/mex.cc:2409:  mutable char *fname;

Instances of mutable found in liboctave:

array/Range.h:153:  mutable Matrix cache;
array/idx-vector.h:424:    mutable octave_idx_type lsti;
array/idx-vector.h:425:    mutable octave_idx_type lste;
system/oct-env.h:139:      mutable std::string current_directory;
system/oct-env.h:142:      mutable std::string prog_name;
system/oct-env.h:144:      mutable std::string prog_invocation_name;
system/oct-env.h:146:      mutable std::string user_name;
system/oct-env.h:148:      mutable std::string host_name;

Rik <rik5>
Project Administrator


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attached Files
file #47886:  libinterp.mutable.list added by rik5 (4KiB - application/octet-stream)
file #47887:  libinterp.mutable.list added by rik5 (4KiB - application/octet-stream)


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by rik5 (Submitted the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2019-11-18 rik5 Attached File- Added libinterp.mutable.list, #47886
        Attached File- Added libinterp.mutable.list, #47887

    Back to the top

    Powered by Savane 3.9