transform samples only when transformers exist

the pipeline is oddly setup to loop through each sample and
attempt to transform it even when there are no transformers. this
is madness and should be stopped -- this patch does this.

at best, this should improve performance because of needless
looping, at worst, we get rid of misleading 'tranforming sample'
logs.

Change-Id: I80ba2b7775fda03670c7fa556ad5a779c6eefd27
This commit is contained in:
gordon chung 2014-11-18 15:40:30 -05:00
parent 2117ba760c
commit bd0889abce

View File

@ -288,15 +288,18 @@ class Sink(object):
"""
transformed_samples = []
for sample in samples:
LOG.debug(_(
"Pipeline %(pipeline)s: Transform sample "
"%(smp)s from %(trans)s transformer") % ({'pipeline': self,
'smp': sample,
'trans': start}))
sample = self._transform_sample(start, ctxt, sample)
if sample:
transformed_samples.append(sample)
if not self.transformers:
transformed_samples = samples
else:
for sample in samples:
LOG.debug(_(
"Pipeline %(pipeline)s: Transform sample "
"%(smp)s from %(trans)s transformer") % ({'pipeline': self,
'smp': sample,
'trans': start}))
sample = self._transform_sample(start, ctxt, sample)
if sample:
transformed_samples.append(sample)
if transformed_samples:
for p in self.publishers: