From 4c1a13bf0759f67f142830902b80c2990727ea04 Mon Sep 17 00:00:00 2001 From: David Capello Date: Tue, 4 May 2021 18:32:38 -0300 Subject: [PATCH 1/2] More info about coding style --- docs/CODING_STYLE.md | 61 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 56 insertions(+), 5 deletions(-) diff --git a/docs/CODING_STYLE.md b/docs/CODING_STYLE.md index 1c1fb8a30..43997b40c 100644 --- a/docs/CODING_STYLE.md +++ b/docs/CODING_STYLE.md @@ -5,18 +5,48 @@ Basic statements: ```c++ -void global_function(int arg1, int arg2, - int arg3, ...) +void global_function(int arg1, + const int arg2, // You can use "const" preferably + const int arg3, ...) { int value; const int constValue = 0; + // We prefer to use "var = (condition ? ...: ...)" instead of + // "var = condition ? ...: ...;" to make clear about the + // ternary operator limits. + int conditionalValue1 = (condition ? 1: 2); + int conditionalValue2 = (condition ? longVarName: + otherLongVarName); + + // If a condition will return, we prefer the "return" + // statement in its own line to avoid missing the "return" + // keyword when we read code. + if (condition) + return; + + // You can use braces {} if the condition has multiple lines + // or the if-body has multiple lines. + if (condition1 || + condition2) { + return; + } + if (condition) { ... + ... + ... } + // We prefer to avoid whitespaces between "var=initial_value" + // or "var Date: Tue, 11 May 2021 16:31:59 -0300 Subject: [PATCH 2/2] Fix crash when remap on palettes with more than 256 colors --- src/doc/remap.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/doc/remap.cpp b/src/doc/remap.cpp index be42491da..fe69dc6f6 100644 --- a/src/doc/remap.cpp +++ b/src/doc/remap.cpp @@ -1,6 +1,6 @@ // Aseprite Document Library -// Copyright (c) 2020 Igara Studio S.A. -// Copyright (c) 2001-2016 David Capello +// Copyright (C) 2019-2021 Igara Studio S.A. +// Copyright (C) 2001-2016 David Capello // // This file is released under the terms of the MIT license. // Read LICENSE.txt for more information. @@ -157,7 +157,8 @@ bool Remap::isFor8bit() const bool Remap::isInvertible(const PalettePicks& usedEntries) const { PalettePicks picks(size()); - for (int i=0; i