Cache the result of makesign() across calls of gtrgm_penalty().
Cache the result of makesign() across calls of gtrgm_penalty().

Since gtrgm_penalty() is usually called many times in a row with the same
"newval" (to determine which item on an index page newval fits into best),
the makesign() calculation is repetitious.  It's expensive enough to make
it worth caching the result, so do so.  On my machine this is good for
more than a 40% savings in the time needed to build a trigram index on
/usr/share/dict/words.  This is all per a suggestion of Heikki's.

In passing, make some mostly-cosmetic improvements in the caching logic in
the other functions in this file that rely on caching info in fn_extra.

yazun/postgres-xl,snaga/postgres-xl,arcivanov/postgres-xl,50wu/gpdb,arcivanov/postgres-xl,yazun/postgres-xl,snaga/postgres-xl,adam8157/gpdb,Postgres-XL/Postgres-XL,techdragon/Postgres-XL,ovr/postgres-xl,jmcatamney/gpdb,yazun/postgres-xl,kmjungersen/PostgresXL,postmind-net/postgres-xl,arcivanov/postgres-xl,50wu/gpdb,ashwinstar/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,zeroae/postgres-xl,ashwinstar/gpdb,adam8157/gpdb,50wu/gpdb,jmcatamney/gpdb,greenplum-db/gpdb,tpostgres-projects/tPostgres,pavanvd/postgres-xl,xinzweb/gpdb,xinzweb/gpdb,xinzweb/gpdb,arcivanov/postgres-xl,arcivanov/postgres-xl,snaga/postgres-xl,adam8157/gpdb,postmind-net/postgres-xl,pavanvd/postgres-xl,Postgres-XL/Postgres-XL,greenplum-db/gpdb,oberstet/postgres-xl,adam8157/gpdb,50wu/gpdb,tpostgres-projects/tPostgres,lisakowen/gpdb,jmcatamney/gpdb,ashwinstar/gpdb,lisakowen/gpdb,postmind-net/postgres-xl,ashwinstar/gpdb,greenplum-db/gpdb,jmcatamney/gpdb,adam8157/gpdb,oberstet/postgres-xl,Postgres-XL/Postgres-XL,yazun/postgres-xl,pavanvd/postgres-xl,jmcatamney/gpdb,50wu/gpdb,oberstet/postgres-xl,kmjungersen/PostgresXL,xinzweb/gpdb,xinzweb/gpdb,oberstet/postgres-xl,Postgres-XL/Postgres-XL,postmind-net/postgres-xl,adam8157/gpdb,lisakowen/gpdb,jmcatamney/gpdb,zeroae/postgres-xl,pavanvd/postgres-xl,Postgres-XL/Postgres-XL,50wu/gpdb,adam8157/gpdb,xinzweb/gpdb,tpostgres-projects/tPostgres,xinzweb/gpdb,techdragon/Postgres-XL,ovr/postgres-xl,zeroae/postgres-xl,greenplum-db/gpdb,ovr/postgres-xl,snaga/postgres-xl,greenplum-db/gpdb,zeroae/postgres-xl,ovr/postgres-xl,greenplum-db/gpdb,postmind-net/postgres-xl,techdragon/Postgres-XL,tpostgres-projects/tPostgres,lisakowen/gpdb,lisakowen/gpdb,xinzweb/gpdb,tpostgres-projects/tPostgres,adam8157/gpdb,kmjungersen/PostgresXL,snaga/postgres-xl,ashwinstar/gpdb,jmcatamney/gpdb,techdragon/Postgres-XL,kmjungersen/PostgresXL,arcivanov/postgres-xl,greenplum-db/gpdb,oberstet/postgres-xl,zeroae/postgres-xl,yazun/postgres-xl,50wu/gpdb,lisakowen/gpdb,ashwinstar/gpdb,ovr/postgres-xl,pavanvd/postgres-xl,ashwinstar/gpdb,lisakowen/gpdb,greenplum-db/gpdb,techdragon/Postgres-XL,50wu/gpdb,lisakowen/gpdb,kmjungersen/PostgresXL