Skip to content

Commit 8fb42f4

Browse files
committed
ext/pdo: Pack _pdo_dbh_t struct
This reduces the size from 176 to 152 bytes
1 parent 1331a61 commit 8fb42f4

File tree

1 file changed

+25
-24
lines changed

1 file changed

+25
-24
lines changed

ext/pdo/php_pdo_driver.h

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -432,42 +432,47 @@ struct _pdo_dbh_t {
432432
void *driver_data;
433433

434434
/* credentials */
435-
char *username, *password;
435+
char *username;
436+
char *password;
436437

437438
/* if true, then data stored and pointed at by this handle must all be
438439
* persistently allocated */
439-
unsigned is_persistent:1;
440+
uint8_t is_persistent:1;
440441

441442
/* if true, driver should act as though a COMMIT were executed between
442443
* each executed statement; otherwise, COMMIT must be carried out manually
443444
* */
444-
unsigned auto_commit:1;
445+
uint8_t auto_commit:1;
445446

446447
/* if true, the handle has been closed and will not function anymore */
447-
unsigned is_closed:1;
448+
uint8_t is_closed:1;
448449

449450
/* if true, the driver requires that memory be allocated explicitly for
450451
* the columns that are returned */
451-
unsigned alloc_own_columns:1;
452+
uint8_t alloc_own_columns:1;
452453

453454
/* if true, commit or rollBack is allowed to be called */
454-
bool in_txn:1;
455+
uint8_t in_txn:1;
455456

456-
/* max length a single character can become after correct quoting */
457-
unsigned max_escaped_char_length:3;
457+
/* when set, convert int/floats to strings */
458+
uint8_t stringify:1;
458459

459460
/* oracle compat; see enum pdo_null_handling */
460-
unsigned oracle_nulls:2;
461+
uint8_t oracle_nulls:2;
461462

462-
/* when set, convert int/floats to strings */
463-
unsigned stringify:1;
463+
/* The PDO Error mode pdo_error_mode */
464+
uint8_t error_mode:2;
464465

465-
/* bitmap for pdo_param_event(s) to skip in dispatch_param_event */
466-
unsigned skip_param_evt:7;
466+
/* max length a single character can become after correct quoting */
467+
uint8_t max_escaped_char_length:3;
468+
469+
/* Case conversion pdo_case_conversion */
470+
uint8_t native_case:2;
471+
uint8_t desired_case:2;
472+
uint8_t _reserved:4;
467473

468-
/* the sum of the number of bits here and the bit fields preceding should
469-
* equal 32 */
470-
unsigned _reserved_flags:14;
474+
/* bitmap for pdo_param_event(s) to skip in dispatch_param_event */
475+
uint8_t skip_param_evt;
471476

472477
/* data source string used to open this handle */
473478
const char *data_source;
@@ -476,14 +481,13 @@ struct _pdo_dbh_t {
476481
/* the global error code. */
477482
pdo_error_type error_code;
478483

479-
enum pdo_error_mode error_mode;
480-
481-
enum pdo_case_conversion native_case, desired_case;
482-
483484
/* persistent hash key associated with this handle */
484485
const char *persistent_id;
485486
size_t persistent_id_len;
486-
unsigned int refcount;
487+
uint32_t refcount;
488+
489+
/* defaults for fetches */
490+
enum pdo_fetch_type default_fetch_type;
487491

488492
/* driver specific "class" methods for the dbh and stmt */
489493
HashTable *cls_methods[PDO_DBH_DRIVER_METHOD_KIND__MAX];
@@ -500,9 +504,6 @@ struct _pdo_dbh_t {
500504
* when PDO::query() fails */
501505
pdo_stmt_t *query_stmt;
502506
zend_object *query_stmt_obj;
503-
504-
/* defaults for fetches */
505-
enum pdo_fetch_type default_fetch_type;
506507
};
507508

508509
/* represents a connection to a database */

0 commit comments

Comments
 (0)