-
Notifications
You must be signed in to change notification settings - Fork 312
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
コマンドが増えると重くなっていくのを改善する #2143
Comments
issue作成ありがとうございます!! 60fpsの1フレームである16msを目指したい、あるいはせめて100ms未満を目指したいですね・・・。
export const createCommandMutation =
<S extends State, M extends MutationsBase, K extends keyof M>(
payloadRecipe: PayloadRecipe<S, M[K]>,
editor: EditorType,
): Mutation<S, M, K> =>
(state: S, payload: M[K]): void => {
const { undoCommands, ...noCommandState } = state; // add this ilne
const command = recordPatches(payloadRecipe)(noCommandState as S, payload); // add this ilne
applyPatchesImpl(state, command.redoPatches);
state.undoCommands[editor].push(command);
state.redoCommands[editor].splice(0);
}; |
あ、issue内容とあまり関係ないのですが、測定はどうやってされましたか? 👀 |
測定のコードです!
|
なるほどです!! 十中八九コマンドのステートが重くなっていくからな気がしますね!! |
内容
コマンドは
state.redoCommands
とstate.undoCommands
で保持していますが、コマンドが増えるとstateが大きくなり、stateが大きくなると
produceWithPatches
で時間がかかるようになって、UIが重く(編集時に一瞬固まるように)なります。これを改善したいです。
コマンドの数と
produceWithPatches
にかかる時間の関係は以下の通りです。(
COMMAND_UPDATE_NOTES
の方はノートが600個ある状態で計測しています)COMMAND_ADD_NOTES
COMMAND_UPDATE_NOTES
Pros 良くなる点
Cons 悪くなる点
実現方法
その他
The text was updated successfully, but these errors were encountered: