Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit1857754

Browse files
committed
Use heap_attisnull, rather than heap_getattr, for a small
but useful speedup.
1 parentd03e987 commit1857754

File tree

1 file changed

+13
-19
lines changed

1 file changed

+13
-19
lines changed

‎src/backend/access/common/printtup.c

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.38 1999/01/2405:40:47 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.39 1999/01/2422:50:58 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -91,27 +91,24 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
9191
pq_putnchar("D",1);
9292

9393
/* ----------------
94-
*send a bitmap of which attributes are null
94+
*send a bitmap of which attributes arenotnull
9595
* ----------------
9696
*/
9797
j=0;
9898
k=1 <<7;
99-
for (i=0;i<tuple->t_data->t_natts;)
99+
for (i=0;i<tuple->t_data->t_natts;++i)
100100
{
101-
i++;/* heap_getattr is a macro, so no
102-
* increment */
103-
attr=heap_getattr(tuple,i,typeinfo,&isnull);
104-
if (!isnull)
105-
j |=k;
101+
if (!heap_attisnull(tuple,i+1))
102+
j |=k;/* set bit if not null */
106103
k >>=1;
107-
if (!(i&7))
104+
if (k==0)/* end of byte? */
108105
{
109106
pq_putint(j,1);
110107
j=0;
111108
k=1 <<7;
112109
}
113110
}
114-
if (i&7)
111+
if (k!= (1 <<7))/* flush last partial byte */
115112
pq_putint(j,1);
116113

117114
/* ----------------
@@ -243,27 +240,24 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
243240
pq_putnchar("B",1);
244241

245242
/* ----------------
246-
*send a bitmap of which attributes are null
243+
*send a bitmap of which attributes arenotnull
247244
* ----------------
248245
*/
249246
j=0;
250247
k=1 <<7;
251-
for (i=0;i<tuple->t_data->t_natts;)
248+
for (i=0;i<tuple->t_data->t_natts;++i)
252249
{
253-
i++;/* heap_getattr is a macro, so no
254-
* increment */
255-
attr=heap_getattr(tuple,i,typeinfo,&isnull);
256-
if (!isnull)
257-
j |=k;
250+
if (!heap_attisnull(tuple,i+1))
251+
j |=k;/* set bit if not null */
258252
k >>=1;
259-
if (!(i&7))
253+
if (k==0)/* end of byte? */
260254
{
261255
pq_putint(j,1);
262256
j=0;
263257
k=1 <<7;
264258
}
265259
}
266-
if (i&7)
260+
if (k!= (1 <<7))/* flush last partial byte */
267261
pq_putint(j,1);
268262

269263
/* ----------------

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp