GithubHelp home page GithubHelp logo

Comments (13)

wangning0 avatar wangning0 commented on May 28, 2024 4

@MrErHu Preact除了只是实现一个精简版的React之外,内部还做了很多的hack,提升了较大的性能,虽然没有React的体系那么庞大,比如没有event system, 但是总体的经常使用的核心API是一致的,加之体积比较小,在一定的程度上更加利于移动端的使用场景,具体内部的实现差异不是很大,preact在内部的diff算法和react部部分不同,生命周期函数内部唤起的机制也有所不同,针对text node做了很多的优化。 我自己分析过preact的源码,通过注释的形式分析的, 需要的话你可以看看 preact_analyse

from blog.

zoubingwu avatar zoubingwu commented on May 28, 2024

哈哈看上篇博客的时候我在知乎上看到了虚拟DOM算法的那篇文章。
研究算法真的挺有意思的,坐等博主更新。

from blog.

youngwind avatar youngwind commented on May 28, 2024

@shadeofgod 已更新完毕。

from blog.

zoubingwu avatar zoubingwu commented on May 28, 2024

看jsperf的图愣了一下,应该是单位时间内的运算次数成10倍,100倍下降,运算时间是增长的吧。
有点容易引起困惑。

from blog.

youngwind avatar youngwind commented on May 28, 2024

@shadeofgod 此处确实写得不对,多谢指出,已更正。

from blog.

MrErHu avatar MrErHu commented on May 28, 2024

preact的出现是为了解决了什么问题呢?单纯只是一个精简版的React吗?

from blog.

youngwind avatar youngwind commented on May 28, 2024

看起来是的,你看官网都这么说。 @MrErHu

Fast 3kB alternative to React with the same ES6 API

from blog.

MrErHu avatar MrErHu commented on May 28, 2024

@youngwind 那两者内部实现的方式差异大吗?

from blog.

MrErHu avatar MrErHu commented on May 28, 2024

@wangning0 解释的真不错,谢谢了~去了解一下

from blog.

jiajianrong avatar jiajianrong commented on May 28, 2024

动态规划,对于两个串,"abcdef" -> "abccde"
求出最小距离是2之后,react还需要如何判断移动哪些字符呢?

**空 a b c d e f
空 0 1 2 3 4 5 6
*a 1 0 1 2 3 4 5
*b 2 1 0 1 2 3 4
*c 3 2 1 0 1 2 3
*c 4 3 2 1 1 2 3
*d 5 4 3 2 1 2 3
*e 6 5 4 3 2 1 2

肉眼判断肯定是把abcdef中间插入c,末尾移除f,就可以转成abccde
程序怎么写?

from blog.

wanhmr avatar wanhmr commented on May 28, 2024

动态规划和分治法(使用递归)的最大区别应该是子问题是否重叠,动态规划应用于子问题重叠(意味着可以使用缓存),而分治法子问题互不相交。

from blog.

demonbibi avatar demonbibi commented on May 28, 2024

动态规划的两个特性:最优子结构和重叠子问题;
你的递归方法进行简单的修改也可以变为动态规划,它其实是自顶向下的求解问题,在递归到达递归边界时出栈并进行问题的计算,但是你没有对子问题进行缓存查询的逻辑,只是单纯的递归了;
你的动态规划方法,它其实是自底向上求解问题,对子问题进行了缓存和查询的逻辑;

from blog.

liduo1997love avatar liduo1997love commented on May 28, 2024

@demonbibi 说的没错,画一个递归的图,就可以看出比如i-1,j-1的情况算了三次,
时间复杂度:动态规划优于递归

from blog.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.