[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[formatting i18n 02/14] CROSSTABS: Eliminate redundant data copying.
From: |
Ben Pfaff |
Subject: |
[formatting i18n 02/14] CROSSTABS: Eliminate redundant data copying. |
Date: |
Sat, 19 Feb 2011 17:42:14 -0800 |
There's no point in copying the output string twice.
---
src/language/stats/crosstabs.q | 13 ++++---------
1 files changed, 4 insertions(+), 9 deletions(-)
diff --git a/src/language/stats/crosstabs.q b/src/language/stats/crosstabs.q
index 02cd4de..e3d0794 100644
--- a/src/language/stats/crosstabs.q
+++ b/src/language/stats/crosstabs.q
@@ -1,5 +1,5 @@
/* PSPP - a program for statistical analysis.
- Copyright (C) 1997-9, 2000, 2006, 2009, 2010 Free Software Foundation, Inc.
+ Copyright (C) 1997-9, 2000, 2006, 2009, 2010, 2011 Free Software
Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -1189,20 +1189,15 @@ create_crosstab_table (struct crosstabs_proc *proc,
struct pivot_table *pt)
for (i = 0; i < pt->n_consts; i++)
{
const struct variable *var = pt->const_vars[i];
- size_t ofs;
- char *s = NULL;
+ char *s;
ds_put_format (&title, ", %s=", var_get_name (var));
- /* Insert the formatted value of the variable, then trim
- leading spaces in what was just inserted. */
- ofs = ds_length (&title);
+ /* Insert the formatted value of VAR without any leading spaces. */
s = data_out (&pt->const_values[i], var_get_encoding (var),
var_get_print_format (var));
- ds_put_cstr (&title, s);
+ ds_put_cstr (&title, s + strspn (s, " "));
free (s);
- ds_remove (&title, ofs, ss_cspan (ds_substr (&title, ofs, SIZE_MAX),
- ss_cstr (" ")));
}
ds_put_cstr (&title, " [");
--
1.7.2.3
- [formatting i18n 00/14] Fix i18n of formatted data, Ben Pfaff, 2011/02/19
- [formatting i18n 03/14] PRINT: Use UTF-8 encoding for output to the output subsystem., Ben Pfaff, 2011/02/19
- [formatting i18n 01/14] Use new Gnulib function dtoastr() to format short, accurate real numbers., Ben Pfaff, 2011/02/19
- [formatting i18n 04/14] i18n: New function recode_byte()., Ben Pfaff, 2011/02/19
- [formatting i18n 10/14] format: Count prefix and suffix width in terms of display columns., Ben Pfaff, 2011/02/19
- [formatting i18n 08/14] data-out: Make each converter responsible for storing null terminator., Ben Pfaff, 2011/02/19
- [formatting i18n 12/14] pool: Support NULL pool argument to pool_alloc_unaligned()., Ben Pfaff, 2011/02/19
- [formatting i18n 14/14] data-out: Add test for non-ASCII custom currency formats., Ben Pfaff, 2011/02/19
- [formatting i18n 11/14] data-out: Reorganize output_Z() to be more easily understood., Ben Pfaff, 2011/02/19
- [formatting i18n 02/14] CROSSTABS: Eliminate redundant data copying.,
Ben Pfaff <=
- [formatting i18n 06/14] legacy-encoding: Remove., Ben Pfaff, 2011/02/19
- [formatting i18n 07/14] format: Increase abstraction of fmt_number_style., Ben Pfaff, 2011/02/19
- [formatting i18n 09/14] format: Create a new "struct fmt_affix" for prefix and suffix strings., Ben Pfaff, 2011/02/19
- [formatting i18n 05/14] i18n: Introduce C_ENCODING as replacement for LEGACY_NATIVE., Ben Pfaff, 2011/02/19
- [formatting i18n 13/14] data-out: Optimize and fix some bad assumptions., Ben Pfaff, 2011/02/19
- Re: [formatting i18n 00/14] Fix i18n of formatted data, Ben Pfaff, 2011/02/23