Giter Club home page Giter Club logo

bitarray's People

Contributors

kamil-tarnas avatar

Watchers

 avatar

bitarray's Issues

Hijack helper objects

Hijack helper objects and analyze theirs layout - they should be smaller - at least according to my common sense. Investigate why they are the size that they are.

Layout of ElemRefHelper object

Size of ElemRefHelper object tested seems to be really big for an object holding only one unsigned and one unsigned reference value. Check the layout of this object.

sizeof(ElemRefHelper) = 16

Get rid of mask calculation in function calls

Mask used to truncate assigned value is static for a template instance. It can be calculated once, per class template instantiation.

The thing to consider is the data locality of such solution. It won't be any surprise if calculating mask each time, on the fly, in function call would be cheaper than the access to static storage data segment.

Get rid of involving padding in calculation

There is more optimal way to pack value elements in words that will make the calculation of padding bits unnecessary. Do more in-depth analysis and opportunity analysis for this change.

Truncation vs throwing exception

Current implementation considers only truncation of assigned values in order to be "safe". Consider implementing exception throwing instead.

Yeah, yeah, I know ;)

BitArrayElemRefHelper use cases

1. Assigning return value of opeartor[] to any integer type

There is a need to be able to subscript BitArray instance variable and assign the return value to any integer-type variable:

Code snippet:
BitArray<10, 2> arrayObject;
int a = arrayObject[2];

Solution:
This would require BitArray::operator int() or some other integer type.

Open problems:

  1. Should we have int(), unsiged(), long() and so on, or only one is sufficient? (Other types will be created by built-in language rules). Or should we have only the one that matches underlying storage type?
  2. Is there any other way to achieve that? Other than defining custom conversion operator for BitArray?

2. Modifying subscripted element

Modifying subscripted element would require modifying underlying storage, ElemRefHelper should contain pointer or reference to specific word of underlying storage to be able to modify it when demanded.

Code snippet:
BitArray<10, 2> arrayObject;
arrayObject[6] = 2;

Solution:
Converting constructor with integer type argument has to be implemented.

Open problems:

  1. What type should be the argument? Would it work fine when passed type that is close enough? (Meaning is convertible by language defined rules.)
  2. Any other way of having this behaviour?

Reorganize template logic

class BitArray<> is probably not a template partial specialization.
The parameter pack on the top of hierarchy of BitArray template is probably not needed?
The template could just omit the unused parameters in case of dynamic?
The BitArray first parameter pack does not need to be unsigned?
Move BitArray top declaration from utils.h to BitArray.h
All the problems stem from the fact that the above points were not clear back then?

Unnecessary copying of ElemRefHelper objects

Unnecessary copying of ElemRefHelper objects - objects are made in internal ElemRefHelper and BitArray implementation. It involves copies being made while switching from BitArray::operator[] creates an object of ElemRefHelper and then in operator unsigned() object of different address is being processed.

Wrapping setting and getting values

Investigate possibilities of wrapping code for getting and setting value of BitArray elements - the current situation is that there is a lot of code duplication. To be more precise, code differs slightly between those uses, so it could not be simply wrapped in some function.

How could it be made?

Merge instead of rebasing

Merge local 'exceptions' branch to mimic 'master'

0b14f82 HEAD@{0}: commit: Removing duplicated line
8c60cb7 HEAD@{1}: rebase finished: returning to refs/heads/exceptions
8c60cb7 HEAD@{2}: rebase: Adding basic testcase to exceptions
256d226 HEAD@{3}: rebase: Adding unnecessary comment to throwing exception code
010c07c HEAD@{4}: rebase: Adding basic throwing if value in Set() is greater than possible bit resolution
aabafcb HEAD@{5}: rebase: Moving mask calculations to compile time, making mask variable static constexpr class template variable
db36cc6 HEAD@{6}: rebase: Adding comments for throwing during Set()
a38a16f HEAD@{7}: rebase: checkout master
dd16759 HEAD@{8}: checkout: moving from master to exceptions
a38a16f HEAD@{9}: checkout: moving from exceptions to master

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.