Giter Site home page Giter Site logo

fcompare's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

ayang64 assaf-v-m

fcompare's Issues

Code review

type filesInfo struct {

What is the filesInfo type for? You don't use it!

filesInformation := []*fileInfo{}

Why pointer? The fileInfo struct occupies only a handful of words, copying it is cheaper than dereferencing the pointer.
Why not allocate the []fileInfo properly - you know its probable size:
filesInformation := make([]fileInfo, 0, len(files))

if !file.IsDir() {

if !file.Mode().IsRegular() { continue }

for i := 0; i < len(filesInformation); i++ {

for _, s := range filesInformation

filesInformation = append(filesInformation[:i], filesInformation[i+1:]...)

Why do you remove it? Your outer iteration is over it, your inner compareFilesSlice is not , but this line is here for its shadowing side effect, not what's written!

By the way, this algorithm is quite inefficient: you hash the files at least twice - at least cache the hash value into fileInfo (which can be a pointer in this case, or re-add it to the map after filling the cache),
and use a map[int64][]fileInfo to group fileInfos by size.

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.