parse_comment: do concatenation in reverse
This commit is contained in:
parent
7191a5690d
commit
71d8988f1a
1 changed files with 5 additions and 4 deletions
|
|
@ -298,11 +298,11 @@ let parse_comment comment =
|
||||||
List.fold_left
|
List.fold_left
|
||||||
(fun (acc_words, acc_cited_posts) w ->
|
(fun (acc_words, acc_cited_posts) w ->
|
||||||
match handle_word w with
|
match handle_word w with
|
||||||
| w, Some cited_id ->
|
| w, Some cited_id -> (w :: acc_words, cited_id :: acc_cited_posts)
|
||||||
(acc_words @ [ w ], acc_cited_posts @ [ cited_id ])
|
| w, None -> (w :: acc_words, acc_cited_posts) )
|
||||||
| w, None -> (acc_words @ [ w ], acc_cited_posts) )
|
|
||||||
([], []) words
|
([], []) words
|
||||||
in
|
in
|
||||||
|
let words = List.rev words in
|
||||||
let line = String.concat (String.make 1 ' ') words in
|
let line = String.concat (String.make 1 ' ') words in
|
||||||
(line, cited_posts)
|
(line, cited_posts)
|
||||||
in
|
in
|
||||||
|
|
@ -314,9 +314,10 @@ let parse_comment comment =
|
||||||
List.fold_left
|
List.fold_left
|
||||||
(fun (acc_lines, acc_cited_posts) l ->
|
(fun (acc_lines, acc_cited_posts) l ->
|
||||||
let line, cited_posts = handle_line l in
|
let line, cited_posts = handle_line l in
|
||||||
(acc_lines @ [ line ], acc_cited_posts @ cited_posts) )
|
(line :: acc_lines, cited_posts @ acc_cited_posts) )
|
||||||
([], []) lines
|
([], []) lines
|
||||||
in
|
in
|
||||||
|
let lines = List.rev lines in
|
||||||
(*insert <br>*)
|
(*insert <br>*)
|
||||||
let comment = String.concat "\n<br>" lines in
|
let comment = String.concat "\n<br>" lines in
|
||||||
(* remove duplicate cited_id *)
|
(* remove duplicate cited_id *)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue