mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
feat: document deepcopyparser
Co-authored-by: Arthur Silva Sens <arthursens2005@gmail.com> Signed-off-by: Manik Rana <Manikrana54@gmail.com> Signed-off-by: Manik Rana <manikrana54@gmail.com>
This commit is contained in:
parent
9c4bc807be
commit
e9391dd61f
|
@ -281,8 +281,10 @@ loop:
|
|||
return nil
|
||||
}
|
||||
|
||||
// We need this because we want offsets of the original parser unchanged when
|
||||
// we're working with a new parser in CreatedTimeStamp().
|
||||
// deepCopyParser creates a copy of a parser without re-using the slices' original memory addresses.
|
||||
// The function `CreatedTimestamp()` uses a copy of the parser to "peek" at _created lines that might be several lines ahead, without changing the state of the original parser.
|
||||
//
|
||||
// Additionally, deepCopyParser switches `skipCT` from false to true, because this new parser needs to return _created lines.
|
||||
func deepCopyParser(p *OpenMetricsParser) OpenMetricsParser {
|
||||
newB := make([]byte, len(p.l.b))
|
||||
copy(newB, p.l.b)
|
||||
|
|
Loading…
Reference in a new issue