Skip to content

Commit

Permalink
Merge pull request #4708 from WalterBright/dtsize
Browse files Browse the repository at this point in the history
Improve small string optimization for dt_t
  • Loading branch information
yebblies authored and WalterBright committed Jun 2, 2015
1 parent e2136e7 commit fc30df5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/backend/cc.h
Original file line number Diff line number Diff line change
Expand Up @@ -1597,12 +1597,13 @@ struct dt_t
{ dt_t *DTnext; // next in list
char dt; // type (DTxxxx)
unsigned char Dty; // pointer type
unsigned char DTn; // DTibytes: number of bytes
union
{
struct // DTibytes
{ char DTn_; // number of bytes
#define DTn _DU._DI.DTn_
char DTdata_[8]; // data
{
#define DTibytesMax (sizeof(char *) + sizeof(unsigned) + sizeof(int) + sizeof(targ_size_t))
char DTdata_[DTibytesMax]; // data
#define DTdata _DU._DI.DTdata_
}_DI;
targ_size_t DTazeros_; // DTazeros,DTcommon,DTsymsize
Expand Down
2 changes: 1 addition & 1 deletion src/backend/dt.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ dt_t ** dtnbytes(dt_t **pdtend,unsigned size,const char *ptr)
pdtend = &((*pdtend)->DTnext);
if (size)
{
if (size <= 7)
if (size < DTibytesMax)
{ dt = dt_calloc(DT_ibytes);
dt->DTn = size;
memcpy(dt->DTdata,ptr,size);
Expand Down

0 comments on commit fc30df5

Please sign in to comment.