commit | 1b80d5725959fa2c70e2ace1f9b27ca7ce20cd56 | [log] [tgz] |
---|---|---|
author | Googler <noreply@google.com> | Thu Nov 14 11:01:25 2019 -0800 |
committer | Copybara-Service <copybara-worker@google.com> | Thu Nov 14 11:03:51 2019 -0800 |
tree | 67e8afbdada19fa3b7a4cf8111ef580989d6dc27 | |
parent | 489a9e5cdf7ca30c789feeca5081d367c7474006 [diff] |
bazel syntax: simplify StarlarkMutable A sequence may be mutable (list) or not (tuple, range). This change breaks the subclass relationship between Sequence and StarlarkMutable so that Tuple and RangeList do not implement it. This change also deletes the StarlarkMutable abstract base classes (BaseMutableWrapper, MutableCollection, BaseMutableList, MutableMap), partly because they would now require Mutable and non-Mutable variants, but more importantly because, through getContentsUnsafe, they force inefficiency on all concrete implementations: either the internal representation must itself be a List, which adds another allocation and indirection, or getContentsUnsafe must lazily allocate a List wrapper, which generates unnecessary garbage. A follow-up change will move the accessor methods down into list and tuple and specialize them to the representation. Pushing MutableMap down into Dict caused it to have two methods named get, one annotated and one not. This exposed a bug in which SkylarkInterfaceUtils.getSkylarkCallable gets confused as two which method has the annotation. For now I renamed Dict.get to get2 as the fix is slightly tricky. StarlarkMutable's lock and unlock methods were in effect moved to EvalUtils. Its isImmutable and isHashable methods are left abstract. They are easy enough for subclasses to implement. The StarlarkMutable class was effectively a "mix in", a base class that one extends to get some help with implementation. Mixins are not a good fit with single-inheritance OO languages. This change makes it an interface with a default implementation of its sole remaining method, checkMutability, that subclasses should really not override. Also: - update the two flavors (mutable/immutable) of Args - delete mutability methods of RangeList and Tuple. - delete SHALLOW_IMMUTABLE, which is no longer needed. - remove unused Mutability from test of serialization. - add some TODOs. PiperOrigin-RevId: 280466438
{Fast, Correct} - Choose two
Build and test software of any size, quickly and reliably.
Speed up your builds and tests: Bazel rebuilds only what is necessary. With advanced local and distributed caching, optimized dependency analysis and parallel execution, you get fast and incremental builds.
One tool, multiple languages: Build and test Java, C++, Android, iOS, Go, and a wide variety of other language platforms. Bazel runs on Windows, macOS, and Linux.
Scalable: Bazel helps you scale your organization, codebase, and continuous integration solution. It handles codebases of any size, in multiple repositories or a huge monorepo.
Extensible to your needs: Easily add support for new languages and platforms with Bazel's familiar extension language. Share and re-use language rules written by the growing Bazel community.
Follow our tutorials:
See CONTRIBUTING.md