Skip to content

Commit b7b8a4d

Browse files
Avoid copies of string preprocess objects
Only one instance of this class should exist for a program.
1 parent 21d89b3 commit b7b8a4d

6 files changed

+12
-9
lines changed

src/java_bytecode/java_bytecode_convert_class.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class java_bytecode_convert_classt:public messaget
3131
size_t _max_array_length,
3232
lazy_methodst& _lazy_methods,
3333
lazy_methods_modet _lazy_methods_mode,
34-
const java_string_library_preprocesst &_string_preprocess):
34+
java_string_library_preprocesst &_string_preprocess):
3535
messaget(_message_handler),
3636
symbol_table(_symbol_table),
3737
max_array_length(_max_array_length),
@@ -63,7 +63,7 @@ class java_bytecode_convert_classt:public messaget
6363
const size_t max_array_length;
6464
lazy_methodst &lazy_methods;
6565
lazy_methods_modet lazy_methods_mode;
66-
java_string_library_preprocesst string_preprocess;
66+
java_string_library_preprocesst &string_preprocess;
6767

6868
// conversion
6969
void convert(const classt &c);
@@ -477,7 +477,7 @@ bool java_bytecode_convert_class(
477477
size_t max_array_length,
478478
lazy_methodst &lazy_methods,
479479
lazy_methods_modet lazy_methods_mode,
480-
const java_string_library_preprocesst &string_preprocess)
480+
java_string_library_preprocesst &string_preprocess)
481481
{
482482
java_bytecode_convert_classt java_bytecode_convert_class(
483483
symbol_table,

src/java_bytecode/java_bytecode_convert_class.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,6 @@ bool java_bytecode_convert_class(
2222
size_t max_array_length,
2323
lazy_methodst &,
2424
lazy_methods_modet,
25-
const java_string_library_preprocesst &string_preprocess);
25+
java_string_library_preprocesst &string_preprocess);
2626

2727
#endif // CPROVER_JAVA_BYTECODE_JAVA_BYTECODE_CONVERT_CLASS_H

src/java_bytecode/java_bytecode_convert_method.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2777,7 +2777,7 @@ void java_bytecode_convert_method(
27772777
message_handlert &message_handler,
27782778
size_t max_array_length,
27792779
safe_pointer<ci_lazy_methodst> lazy_methods,
2780-
const java_string_library_preprocesst &string_preprocess)
2780+
java_string_library_preprocesst &string_preprocess)
27812781
{
27822782
static const std::unordered_set<std::string> methods_to_ignore
27832783
{

src/java_bytecode/java_bytecode_convert_method.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ void java_bytecode_convert_method(
2626
message_handlert &message_handler,
2727
size_t max_array_length,
2828
safe_pointer<ci_lazy_methodst> lazy_methods,
29-
const java_string_library_preprocesst &string_preprocess);
29+
java_string_library_preprocesst &string_preprocess);
3030

3131
inline void java_bytecode_convert_method(
3232
const symbolt &class_symbol,
3333
const java_bytecode_parse_treet::methodt &method,
3434
symbol_tablet &symbol_table,
3535
message_handlert &message_handler,
3636
size_t max_array_length,
37-
const java_string_library_preprocesst &string_preprocess)
37+
java_string_library_preprocesst &string_preprocess)
3838
{
3939
java_bytecode_convert_method(
4040
class_symbol,

src/java_bytecode/java_bytecode_convert_method_class.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class java_bytecode_convert_methodt:public messaget
3333
message_handlert &_message_handler,
3434
size_t _max_array_length,
3535
safe_pointer<ci_lazy_methodst> _lazy_methods,
36-
const java_string_library_preprocesst &_string_preprocess):
36+
java_string_library_preprocesst &_string_preprocess):
3737
messaget(_message_handler),
3838
symbol_table(_symbol_table),
3939
max_array_length(_max_array_length),
@@ -61,7 +61,7 @@ class java_bytecode_convert_methodt:public messaget
6161
irep_idt method_id;
6262
irep_idt current_method;
6363
typet method_return_type;
64-
java_string_library_preprocesst string_preprocess;
64+
java_string_library_preprocesst &string_preprocess;
6565

6666
public:
6767
struct holet

src/java_bytecode/java_string_library_preprocess.h

+3
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ class java_string_library_preprocesst:public messaget
4747
bool is_known_string_type(irep_idt class_name);
4848

4949
private:
50+
// We forbid copies of the object by making the copy operator private.
51+
java_string_library_preprocesst(const java_string_library_preprocesst &);
52+
5053
static bool java_type_matches_tag(const typet &type, const std::string &tag);
5154
static bool is_java_string_pointer_type(const typet &type);
5255
static bool is_java_string_type(const typet &type);

0 commit comments

Comments
 (0)