@@ -33,6 +33,7 @@ type PerfData struct {
33
33
usersByForum map [string ][]* PUser
34
34
postsByThreadFlat map [int32 ][]* PPost
35
35
postsByThreadTree map [int32 ][]* PPost
36
+ postsByThreadParentDesc map [int32 ][]* PPost
36
37
userByNickname map [string ]* PUser
37
38
forumBySlug map [string ]* PForum
38
39
postById map [int64 ]* PPost
@@ -104,6 +105,7 @@ func NewPerfData(config *PerfConfig) *PerfData {
104
105
threadsByForum : map [string ][]* PThread {},
105
106
usersByForum : map [string ][]* PUser {},
106
107
postsByThreadTree : map [int32 ][]* PPost {},
108
+ postsByThreadParentDesc : map [int32 ][]* PPost {},
107
109
postsByThreadFlat : map [int32 ][]* PPost {},
108
110
userByNickname : map [string ]* PUser {},
109
111
forumBySlug : map [string ]* PForum {},
@@ -205,6 +207,7 @@ func (self *PerfData) AddThread(thread *PThread) {
205
207
self .threads = append (self .threads , thread )
206
208
self .threadById [thread .ID ] = thread
207
209
self .postsByThreadTree [thread .ID ] = []* PPost {}
210
+ self .postsByThreadParentDesc [thread .ID ] = []* PPost {}
208
211
self .postsByThreadFlat [thread .ID ] = []* PPost {}
209
212
self .threadsByForum [thread .Forum .Slug ] = append (self .threadsByForum [thread .Forum .Slug ], thread )
210
213
self .usersByForum [thread .Forum .Slug ] = append (self .usersByForum [thread .Forum .Slug ], thread .Author )
@@ -343,6 +346,13 @@ func (self *PerfData) GetThreadPostsTree(thread *PThread) []*PPost {
343
346
return self .postsByThreadTree [thread .ID ]
344
347
}
345
348
349
+ func (self * PerfData ) GetThreadPostsParentDesc (thread * PThread ) []* PPost {
350
+ self .mutex .RLock ()
351
+ defer self .mutex .RUnlock ()
352
+
353
+ return self .postsByThreadParentDesc [thread .ID ]
354
+ }
355
+
346
356
func (self * PerfData ) AddPost (post * PPost ) {
347
357
self .mutex .Lock ()
348
358
defer self .mutex .Unlock ()
@@ -363,9 +373,9 @@ func (self *PerfData) AddPost(post *PPost) {
363
373
post .Path = []int32 {post .Index }
364
374
}
365
375
366
- tree := append (self .postsByThreadTree [post .Thread .ID ], post )
367
376
self .postsByThreadFlat [post .Thread .ID ] = append (self .postsByThreadFlat [post .Thread .ID ], post )
368
- self .postsByThreadTree [post .Thread .ID ] = tree
377
+ self .postsByThreadTree [post .Thread .ID ] = append (self .postsByThreadTree [post .Thread .ID ], post )
378
+ self .postsByThreadParentDesc [post .Thread .ID ] = append (self .postsByThreadParentDesc [post .Thread .ID ], post )
369
379
370
380
post .Thread .Forum .Posts ++
371
381
post .Thread .Posts ++
@@ -379,6 +389,9 @@ func (self *PerfData) Normalize() {
379
389
for _ , threads := range self .threadsByForum {
380
390
sort .Sort (PThreadByCreated (threads ))
381
391
}
392
+ for _ , posts := range self .postsByThreadParentDesc {
393
+ sort .Sort (PPostSortParentDesc (posts ))
394
+ }
382
395
for key , users := range self .usersByForum {
383
396
sort .Sort (PUserByNickname (users ))
384
397
size := 0
0 commit comments