Skip to content

Commit fe8d39a

Browse files
authored
ext/pdo: Pack _pdo_dbh_t struct (php#17741)
This reduces the size from 176 to 152 bytes
1 parent cd65240 commit fe8d39a

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

ext/pdo/php_pdo_driver.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -435,58 +435,61 @@ struct _pdo_dbh_t {
435435
void *driver_data;
436436

437437
/* credentials */
438-
char *username, *password;
438+
char *username;
439+
char *password;
439440

440441
/* if true, then data stored and pointed at by this handle must all be
441442
* persistently allocated */
442-
unsigned is_persistent:1;
443+
bool is_persistent:1;
443444

444445
/* if true, driver should act as though a COMMIT were executed between
445446
* each executed statement; otherwise, COMMIT must be carried out manually
446447
* */
447-
unsigned auto_commit:1;
448+
bool auto_commit:1;
448449

449450
/* if true, the handle has been closed and will not function anymore */
450-
unsigned is_closed:1;
451+
bool is_closed:1;
451452

452453
/* if true, the driver requires that memory be allocated explicitly for
453454
* the columns that are returned */
454-
unsigned alloc_own_columns:1;
455+
bool alloc_own_columns:1;
455456

456457
/* if true, commit or rollBack is allowed to be called */
457458
bool in_txn:1;
458459

459-
/* max length a single character can become after correct quoting */
460-
unsigned max_escaped_char_length:3;
461-
462-
/* oracle compat; see enum pdo_null_handling */
463-
unsigned oracle_nulls:2;
464-
465460
/* when set, convert int/floats to strings */
466-
unsigned stringify:1;
461+
bool stringify:1;
467462

468463
/* bitmap for pdo_param_event(s) to skip in dispatch_param_event */
469-
unsigned skip_param_evt:7;
464+
uint8_t skip_param_evt;
465+
466+
/* The PDO Error mode; see enum pdo_error_mode */
467+
uint8_t error_mode;
468+
469+
/* oracle compat; see enum pdo_null_handling */
470+
uint8_t oracle_nulls;
471+
472+
/* Case conversion; see enum pdo_case_conversion */
473+
uint8_t native_case;
474+
uint8_t desired_case;
470475

471-
/* the sum of the number of bits here and the bit fields preceding should
472-
* equal 32 */
473-
unsigned _reserved_flags:14;
476+
/* max length a single character can become after correct quoting */
477+
uint8_t max_escaped_char_length;
474478

475479
/* data source string used to open this handle */
476480
const char *data_source;
477481
size_t data_source_len;
478482

479483
/* the global error code. */
480484
pdo_error_type error_code;
481-
482-
enum pdo_error_mode error_mode;
483-
484-
enum pdo_case_conversion native_case, desired_case;
485+
/* defaults for fetches */
486+
uint16_t default_fetch_type;
485487

486488
/* persistent hash key associated with this handle */
487489
const char *persistent_id;
488490
size_t persistent_id_len;
489-
unsigned int refcount;
491+
492+
uint32_t refcount;
490493

491494
/* driver specific "class" methods for the dbh and stmt */
492495
HashTable *cls_methods[PDO_DBH_DRIVER_METHOD_KIND__MAX];
@@ -503,9 +506,6 @@ struct _pdo_dbh_t {
503506
* when PDO::query() fails */
504507
pdo_stmt_t *query_stmt;
505508
zend_object *query_stmt_obj;
506-
507-
/* defaults for fetches */
508-
enum pdo_fetch_type default_fetch_type;
509509
};
510510

511511
/* represents a connection to a database */

0 commit comments

Comments
 (0)