@@ -210,7 +210,7 @@ class sqlite_index_blaster : public btree_handler<sqlite_index_blaster> {
210210
211211 // Writes data into buffer to form first page of Sqlite db
212212 int write_page0 (int total_col_count, int pk_col_count,
213- std::string col_names, std::string table_name = {}) {
213+ const std::string& col_names, const std::string& table_name = {}) {
214214
215215 if (block_size % 512 || block_size < 512 || block_size > 65536 )
216216 throw SQLT_RES_INV_PAGE_SZ;
@@ -256,9 +256,9 @@ class sqlite_index_blaster : public btree_handler<sqlite_index_blaster> {
256256 init_bt_tbl_leaf (current_block + 100 );
257257
258258 // write table script record
259- std::string default_table_name = " idx1" ;
260- if (table_name.empty ())
261- table_name = default_table_name ;
259+ std::string tbl_name = " idx1" ;
260+ if (! table_name.empty ())
261+ tbl_name = table_name ;
262262 // write table script record
263263 int col_count = 5 ;
264264 // if (table_script) {
@@ -267,7 +267,7 @@ class sqlite_index_blaster : public btree_handler<sqlite_index_blaster> {
267267 // return SQLT_RES_TOO_LONG;
268268 // set_col_val(4, SQLT_TYPE_TEXT, table_script, script_len);
269269 // } else {
270- int table_name_len = table_name .length ();
270+ int table_name_len = tbl_name .length ();
271271 // len("CREATE TABLE ") + table_name_len + len(" (")
272272 // + len("PRIMARY KEY (") + len(") WITHOUT ROWID")
273273 size_t script_len = 13 + table_name_len + 2 + 13 + 15 ;
@@ -289,13 +289,13 @@ class sqlite_index_blaster : public btree_handler<sqlite_index_blaster> {
289289 // 100 byte header, 2 byte ptr, 3 byte rec/hdr vlen, 1 byte rowid
290290 // 6 byte hdr len, 5 byte "table", twice table name, 4 byte uint32 root
291291 if (script_len > (block_size - 100 - page_resv_bytes - blk_hdr_len
292- - 2 - 3 - 1 - 6 - 5 - table_name .length () * 2 - 4 ))
292+ - 2 - 3 - 1 - 6 - 5 - tbl_name .length () * 2 - 4 ))
293293 return SQLT_RES_TOO_LONG;
294294 uint8_t *script_loc = current_block + block_size - page_resv_bytes - script_len;
295295 uint8_t *script_pos = script_loc;
296296 memcpy (script_pos, " CREATE TABLE " , 13 );
297297 script_pos += 13 ;
298- memcpy (script_pos, table_name .c_str (), table_name_len);
298+ memcpy (script_pos, tbl_name .c_str (), table_name_len);
299299 script_pos += table_name_len;
300300 *script_pos++ = ' ' ;
301301 *script_pos++ = ' (' ;
@@ -312,7 +312,7 @@ class sqlite_index_blaster : public btree_handler<sqlite_index_blaster> {
312312 script_pos += 15 ;
313313 // }
314314 int32_t root_page_no = 2 ;
315- const void *master_rec_values[] = {" table" , table_name .c_str (), table_name .c_str (), &root_page_no, script_loc};
315+ const void *master_rec_values[] = {" table" , tbl_name .c_str (), tbl_name .c_str (), &root_page_no, script_loc};
316316 const size_t master_rec_col_lens[] = {5 , table_name.length (), table_name.length (), sizeof (root_page_no), script_len};
317317 const uint8_t master_rec_col_types[] = {SQLT_TYPE_TEXT, SQLT_TYPE_TEXT, SQLT_TYPE_TEXT, SQLT_TYPE_INT32, SQLT_TYPE_TEXT};
318318 int res = write_new_rec (0 , 1 , 5 , master_rec_values, master_rec_col_lens, master_rec_col_types);
@@ -507,11 +507,11 @@ class sqlite_index_blaster : public btree_handler<sqlite_index_blaster> {
507507 unsigned long child_addr;
508508 int pk_count;
509509 int column_count;
510- std::string column_names;
511- std::string table_name;
510+ const std::string column_names;
511+ const std::string table_name;
512512 int blk_hdr_len;
513513 sqlite_index_blaster (int total_col_count, int pk_col_count,
514- std::string col_names, std::string tbl_name = NULL ,
514+ const std::string& col_names, const std::string& tbl_name = {} ,
515515 int block_sz = BPT_DEFAULT_BLOCK_SIZE, int cache_sz = 0 ,
516516 const char *fname = NULL ) : column_count (total_col_count), pk_count (pk_col_count),
517517 column_names (col_names), table_name (tbl_name),
0 commit comments