Skip to content

feat: new APIs of merge, diff and update#38

Draft
xiegx94 wants to merge 2 commits into
bytedance:masterfrom
xiegx94:feat/merge-diff-update
Draft

feat: new APIs of merge, diff and update#38
xiegx94 wants to merge 2 commits into
bytedance:masterfrom
xiegx94:feat/merge-diff-update

Conversation

@xiegx94

@xiegx94 xiegx94 commented Dec 20, 2022

Copy link
Copy Markdown
Collaborator

Main Changes

  • Implement MergePatch and Merge API following RFC 7386 API.
  • Provide UpdateFrom and Update API
  • Remove GenericNode template parameter Allocator.
using alloc_type =
typename NodeTraits<NodeType>::alloc_type; ///< Dervied class allocator
///< type.
using Allocator = alloc_type;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

allocator 名字和 alloc_type 重复

Comment thread include/sonic/dom/genericnode.h Outdated
typename std::enable_if<is_base_of_template<T, GenericNode>::value &&
is_base_of_template<P, GenericNode>::value,
bool>::type = false>
static inline void Merge(T& original, const P& patch, Allocator& alloc) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

可能做出 genericnode的成员函数会比较好?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GenericNode里提供了 MergePatch 的方法,实现了 Merge 的语义

Comment thread include/sonic/dom/genericnode.h Outdated
typename std::enable_if<is_base_of_template<T, GenericNode>::value &&
is_base_of_template<S, GenericNode>::value,
bool>::type = false>
static inline void Update(T& original, const S& src, Allocator& alloc) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不用模板参数,使用 inherit 命名?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

没有必要吧,两者逻辑差不多,只有些微区别。额外添加一个函数反而维护起来很麻烦。

@xiegx94 xiegx94 changed the title feat: New APIs of merge, diff and update Jan 6, 2023
@xiegx94

xiegx94 commented Mar 8, 2023

Copy link
Copy Markdown
Collaborator Author

Remove diff API.

Comment thread include/sonic/dom/genericnode.h Outdated
@xiegx94 xiegx94 force-pushed the feat/merge-diff-update branch from 14ce2e2 to 6e4a0ed Compare March 8, 2023 07:59
@liuq19 liuq19 marked this pull request as draft November 18, 2024 03:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants